VirtualHost - Proxy Redirect Problem

juanginx nginx-forum at
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
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

This is my conf for the virtual domain:


upstream dom {
        server 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_in_redirect off;  # added as a posible fix but did't
        log_format  main  '$remote_addr - $remote_user [$time_local]
$request '
$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_pass http://dom;
            proxy_redirect off;



Hope you can help me with this issue,

Many thanks!

Posted at Nginx Forum:,152978,152978#msg-152978

More information about the nginx mailing list