Nginx rewrites URL

P lva ruvikal at gmail.com
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 {
server_name app1.company.domain.com;
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
resolve app1.company.domain.com
I'm not sure where the problem lies, and would really appreciate any
pointers.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180118/4767f69e/attachment.html>


More information about the nginx mailing list