0

I've follow the instructions asked here, but it still changes the request url for both 80 and 443 server, does anybody have the same issue?

I'am using the OS X El Capitan 10.11.4, and I use the same nginx.conf and it works perfectly and preserves the request url on Ubuntu 12.04.5 LTS.

Below is my proxy setting.

location / {
    proxy_pass   http://my_app_upstream/;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_set_header        Host            $host;
}

for the installation I use brew install nginx on Mac and self-compiled one on Ubuntu

Community
  • 1
  • 1
Hui-Yu Lee
  • 909
  • 8
  • 20
  • 2
    What do mean when you say the request URL changes? What does it change from/to? In the link that you provided, it is also noted that you should not include / when proxy_passing. So try `proxy_pass http://my_app_upstream;` instead of `proxy_pass http://my_app_upstream/;` and see if it helps. – Keenan Lawrence Jul 01 '16 at 11:30
  • okay, I'll try it next Monday and be back, thank you. – Hui-Yu Lee Jul 01 '16 at 13:35
  • @iownthegame, ping, have you tried yet? – cnst Jul 11 '16 at 17:16
  • I've tried.... and it's my mistake actually :( Ngix did `proxy_pass`, but my code redirect the page again.... so both with or without slash work for me :p I vote you but I cannot mark it as answer, sorry and thank you anyway. – Hui-Yu Lee Jul 12 '16 at 03:42
  • @iownthegame, thanks for upvote! you should probably still accept some answer if the problem is resolved, so that the question does not show up as unsolved. – cnst Jul 12 '16 at 06:41
  • @cnst thanks for your reminder! – Hui-Yu Lee Jul 12 '16 at 06:50

1 Answers1

2

If you don't want the URL to change (e.g., due to Nginx pass_proxy subdirectory without url decoding), you should omit the trailing slash from your proxy_pass:

-proxy_pass   http://my_app_upstream/;
+proxy_pass   http://my_app_upstream;
Community
  • 1
  • 1
cnst
  • 25,870
  • 6
  • 90
  • 122