VirtualHost - Proxy Redirect Problem

juanginx nginx-forum at nginx.us
Wed Nov 24 18:24:31 MSK 2010


Hello Experts,

I am trying to load balance a virtual domain with nginx listening in
port 81. I am using 2 apache server;s as backends servers to distribute
it.
The problem is when I request an url and nginx proxies it to the
localhost server. 
I changed the value on server_name_in_redirect to off, but I am still
getting the false url, pointed to localhost/
One thing that it looks weird to me is that the request goes OK when
nginx chooses to redirect to the 2nd server. The problem is only when
redirects to 127.0.0.1:80.

This is my conf for the virtual domain:

[code]

upstream dom {
        server 127.0.0.1:80 weight=2; # this doesn't work fine
        server xx.xx.xx.xx:80 weight=8; # this shows me the correct url
}

   server {
        listen       81;
        server_name  virtualdomain.net;
        server_name_in_redirect off;  # added as a posible fix but did't
work
        log_format  main  '$remote_addr - $remote_user [$time_local]
$request '
                                                        '"$status"
$body_bytes_sent "$http_referer" '
                                                       
'"$http_user_agent" "$http_x_forwarded_for"';

        access_log  logs/virtualdomain.log;

        location / {

             proxy_set_header        Host            $host;
             proxy_set_header        X-Real-IP       $remote_addr;
             proxy_set_header        X-Forwarded-For
$proxy_add_x_forwarded_for;

            proxy_pass http://dom;
            proxy_redirect off;

        }
}

[/code]

Hope you can help me with this issue,

Many thanks!

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




More information about the nginx mailing list