Nginx rewrites URL

P lva ruvikal at
Thu Jan 18 18:01:44 UTC 2018

Hello Everyone,

I'm trying to get nginx server configured as a reverse proxy serving
requests to few application servers upstream.

Server {
listen 80;

location / {
    proxy_pass http://appserver1:app1port/;
    proxy_pass_request_body on;
    proxy_intercept_errors on;
    error_page 301 302 307 = @handle_redirect;

location @handle_redirect {
    set $saved_redirect_location '$upstream_http_location';
    proxy_pass $saved_redirect_location;
I'm having two challenges with this.

1) This doesn't work with the firewalls. I can get to it only if I open
appserver1 to accept everyone on that app1port. I tried replacing the
headers but none of them work.

2) This configuration works when I turn off the firewall, but the address
in the address bar gets rewritten to http://appserver1:app1port which is a
a dealbreaker as we definitely don't want to have the upstream server
appear in the address bar.

Also these servers (nginx server and the upstream app server) aren't
connected to the same DNS as the client. So neither of these servers can
I'm not sure where the problem lies, and would really appreciate any

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list