proxy server needs to point to two servers

x7311 nginx-forum at nginx.us
Fri Jun 29 18:42:16 UTC 2012


Hi all.

Our machines are behind a private firewall. I have a master machine as
proxy server so two machines (production and development) can be
accessed publicly. 

So I can access production as  http://public_url/app1, 
http://public_url/app2,  http://pbulic_url/app3
and development as
http://public_url/dev/app1, etc  (actually, dev.public_url) would be a
better option.

However, with the config below, I cannot access the development machine
at all. 

This is the site-enabled/default configuration we have on the proxy
server

server {
        listen 80;
        client_max_body_size 200M;
        server_name localhost 127.0.0.1;
        server_name_in_redirect off;

        location / {
                proxy_pass http://10.10.0.59;
                proxy_redirect default;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
        }
}

and I want to add a second server block because I need to support
development server as well.

My attempt with the second server block...

server {
        listen 80;
        client_max_body_size 200M;
        server_name localhost 127.0.0.1;
        server_name_in_redirect off;

        location ^~ /dev/ {
                proxy_pass http://10.10.0.56;
                proxy_redirect default;
                rewrite /dev/(.*) /$1 break;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
        }
}

How can I fix my error? I know I am terrible with nginx configuration...
thanks!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,228113,228113#msg-228113



More information about the nginx mailing list