reverse proxying with NGINX to two back-end servers

Posted by aag on Server Fault See other posts from Server Fault or by aag
Published on 2014-08-24T12:35:33Z Indexed on 2014/08/24 16:22 UTC
Read the original article Hit count: 191

Filed under:
|

I am trying to learn how to configure the Nginx proxy. All requests from external (www.external.com) should go to internal server 10.10.10.16:2080, except for www.external.com/nagios requests, which should go to internal 10.10.10.18.

My location block looks as follows:

    location ~* / {
        proxy_buffers 16 4k;
        proxy_buffer_size 2k;
        proxy_buffering off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Accept-Encoding "";
        proxy_pass http://10.10.10.16:2080;
        }       

    # # nagios server
    location  ~* /nagios/  {
        proxy_buffers 16 4k;
        proxy_buffer_size 2k;
        proxy_buffering off;
        # proxy_set_header Host $host;
        # proxy_set_header X-Real-IP $remote_addr;
        # proxy_set_header Accept-Encoding "";
        proxy_pass http://10.10.10.18;
        }

The first location seems to work fine. However, any request to www.external.com/nagios sends the browser into the eternal pastures. Of course, 10.10.10.18/nagios was tested and works fine. What am I missing?

© Server Fault or respective owner

Related posts about nginx

Related posts about reverse-proxy