Nginx reverse proxy returns incorrect url

0

I have the following setup:

  • public, dynamic IP from my ISP, dynamical DNS let's call it public.org
  • Reverse-proxy (nginx,ubuntu 14.04)
  • Webservers (nginx,ubuntu 14.04) A,B,C running webapps within my home network, let's call it private.home

My goal is to reach the webservers A.private.home, B.private.home,... from the internet via the reverse-proxy as A.public.org

For server A I have set up the following lines on the reverse proxy:

server{

    listen          80;
    server_name     A.public.org;

    location /{
            proxy_pass http://A.private.home;
    }
}

if I then navigate to http://A.public.org from an outside device, I get a 404, saying that A.private.home could (obviously) not be resolved.

Help would be greatly appreciated.

Michael

Posted 2015-03-16T18:05:46.440

Reputation: 1

Answers

0

So I now can provide an anser myself now.

The actual problem was a rewrite happening on A.private.home which rewrote http://A.private.home to https://A.private.home. Thanks Dinoosh for getting my attention on the settings of the webapp. After removing that rewrite, everything worked perfectly.

Michael

Posted 2015-03-16T18:05:46.440

Reputation: 1

0

Please check your domain name is correctly pointed to the server.

use dig command to check your dns record.

dig a A.public.org

Dinoosh

Posted 2015-03-16T18:05:46.440

Reputation: 1

Looks good.

`$ dig A.public.org

; <<>> DiG 9.8.3-P1 <<>> A.public.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40168
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0,        ADDITIONAL: 0

;; QUESTION SECTION:
;A.public.org. IN A

;; ANSWER SECTION:
A.public.org. 58 IN A --somepublicip--

;; Query time: 1489 msec
;; SERVER: X.X.X.X#53(X.X.X.X)
;; WHEN: Tue Mar 17 10:10:33 2015
;; MSG SIZE  rcvd: 60`
 – None  – 2015-03-17T09:14:34.850

check your nginx access.log and error.log to see if it shows any entries when you go to your site from outside device. – None – 2015-03-17T10:02:09.447

Hi, access log shows entries correctly somepublicip --[17/Mar/2015:11:12:07 +0100] "GET / HTTP/1.1" 301 193 "-" "Mozilla/5.0 (iPad; CPU OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/41.0.2272.56 Mobile/12B466 Safari/600.1.4" – None – 2015-03-17T10:14:26.580

can you dig A.private.home from proxy server. If you can try telneting to port 80 of your app servers from proxy server. – None – 2015-03-17T10:23:18.140

both works well. However I should point out, that http://A.private.home automatically redirects to https://A.private.home to protect the user's credentials. (http on the proxy is also just a POC and I will move on to https, as soon as I get things to work properly) – None – 2015-03-17T10:36:43.563