# VirtualHost - Proxy Redirect Problem

**URL:** <https://www.ruby-forum.com/t/virtualhost-proxy-redirect-problem/199587>\
**Category:** NGINX\
**Created:** [November 24, 2010, 4:25pm UTC](https://www.ruby-forum.com/t/virtualhost-proxy-redirect-problem/199587 "2010-11-24T16:25:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 24, 2010, 4:25pm UTC](https://www.ruby-forum.com/t/virtualhost-proxy-redirect-problem/199587/1 "2010-11-24T16:25:53Z")

</div>

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:

```auto

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;

        }
}

```

Hope you can help me with this issue,

Many thanks!

Posted at Nginx Forum:

> **[VirtualHost - Proxy Redirect Problem](https://forum.nginx.org/read.php?2,152978,152978#msg-152978)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![juanginx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/74df32/32.png) [@juanginx](https://www.ruby-forum.com/u/juanginx)\
**Post date:** [November 24, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/virtualhost-proxy-redirect-problem/199587/2 "2010-11-24T16:42:14Z")

</div>

More info:

It’s redireccting to /var/www/munin/localhost/ and it should be looking  
in /var/www/vhosts/virtualhost/

Posted at Nginx Forum:

> **[Re: VirtualHost - Proxy Redirect Problem](https://forum.nginx.org/read.php?2,152978,152983#msg-152983)**
>
> 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...
