# Reverse proxy - several virtual host - same proxy pass ip - getting wrong content

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-several-virtual-host-same-proxy-pass-ip-getting-wrong-content/185662>\
**Category:** NGINX\
**Created:** [March 24, 2010, 10:35am UTC](https://www.ruby-forum.com/t/reverse-proxy-several-virtual-host-same-proxy-pass-ip-getting-wrong-content/185662 "2010-03-24T10:35:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 24, 2010, 10:35am UTC](https://www.ruby-forum.com/t/reverse-proxy-several-virtual-host-same-proxy-pass-ip-getting-wrong-content/185662/1 "2010-03-24T10:35:07Z")

</div>

Hi

I am using nginx as reverse proxy and i have several names pointing to  
reverse proxy and i am using proxy cache. My backends are basic LAMP  
servers and IBM Lotus Domino servers.

Just wondering whats wrong as i changed domain to point my new nginx  
server and i am getting wrong content, i am getting wrong virtual host  
index page.

eg. i am trying to [http://www.silverice.org/](http://www.silverice.org/) and i am getting content  
from  
[http://www.etappi.com/](http://www.etappi.com/) they reside same LAMP-server. Looking my nginx  
configuration i cant find anything wrong.  
both named points to new nginx reverse proxy server. nginx version  
0.7.65

Here is example from my config:

my main config, main parts:  
------------8\<--------------------------------  
http {  
proxy\_cache\_path /usr/share/nginx/cache levels=1:2  
keys\_zone=one:10m  
max\_size=1G;  
proxy\_temp\_path /usr/share/nginx/tmp;

```
proxy_cache_valid 200 302 5m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;

 proxy_cache one;

```

gzip\_http\_version 1.1;  
gzip\_vary on;  
gzip\_min\_length 1100;  
gzip\_buffers 16 8k;  
gzip\_disable “MSIE [1-6].(?!.\*SV1)”;  
gzip\_proxied any;  
gzip\_types text/css text/plain application/atom+xml  
application/x-javascript application/xml text/javascript  
application/xml+rss;  
gzip on;

server\_tokens off;  
client\_header\_timeout 3m;  
send\_timeout 3m;  
client\_header\_buffer\_size 1k;  
large\_client\_header\_buffers 4 4k;  
output\_buffers 1 32k;  
postpone\_output 1460;  
sendfile on;  
tcp\_nopush on;  
tcp\_nodelay on;  
keepalive\_timeout 75 20;  
server\_names\_hash\_bucket\_size 128; # this seems to be required for  
some  
vh

log\_format main '$remote\_addr - $remote\_user [$time\_local] $request  
’  
'“$status” $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

proxy\_redirect off;  
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\_connect\_timeout 90;  
proxy\_send\_timeout 90;  
proxy\_read\_timeout 90;

# default virtual host

```
server {
    listen 80 default;
    server_name _;

    access_log /var/log/nginx/default-access.log main;

    server_name_in_redirect off;

    location / {
        index index.html;
        root /var/www/default/htdocs;
    }

```

}

# here resides my virtual host configurations

include /etc/nginx/virtual-hosts/\*;

}

and my virtual hosts under: /etc/nginx/virtual-hosts -directory:

they all look like this:  
[www.silverice.org](http://www.silverice.org):  
--------------------------8\<----------------

# redirect [silverice.org](http://silverice.org) → [www.silverice.org](http://www.silverice.org)

server {  
server\_name [silverice.org](http://silverice.org);  
rewrite ^/(.\*)$ [http://www.silverice.org/$1](http://www.silverice.org/$1) permanent;  
}

server {  
server\_name [www.silverice.org](http://www.silverice.org);  
access\_log  
/somedirectory/www.silverice.org/www.silverice.org-access\_log combined;  
default\_type text/html;  
root /usr/share/nginx/huolto;

location / {

```
  proxy_pass http://ip.add.re.ss;

  # manual maintenance window
  include /etc/nginx/maintenance.conf;

```

}

# custom errorpages

include /etc/nginx/errorpages.conf;

# general block rules, security rules, etc

include /etc/nginx/suojaus.conf;  
}  
-----------------------------8\<------------------  
And other virtual host like [www.etappi.com](http://www.etappi.com) looks like that, except name  
and access log changed.

How come when trying to load [www.silverice.org](http://www.silverice.org) i am getting  
[www.etappi.com](http://www.etappi.com)  
content, mainly index page comes from wrong site.

Looking backend logs i cant find error there, nothing has changed there,  
name based virtual host there, Apache v2.

Terveisin/Regards,  
Pekka Panula, Sofor Oy - Jatkuvat palvelut

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 24, 2010, 11:43am UTC](https://www.ruby-forum.com/t/reverse-proxy-several-virtual-host-same-proxy-pass-ip-getting-wrong-content/185662/2 "2010-03-24T11:43:35Z")

</div>

you need to set a cache key based on the hostname (or something  
dynamic) else you will serve caches content as (index.HTML) from site1  
for site2 and site3… index requests

## Regards,

Payam Tarverdyan Chychi  
Network Engineer

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 24, 2010, 12:06pm UTC](https://www.ruby-forum.com/t/reverse-proxy-several-virtual-host-same-proxy-pass-ip-getting-wrong-content/185662/3 "2010-03-24T12:06:26Z")

</div>

Thanks, that did fix it.

Terveisin/Regards,  
Pekka Panula, Sofor Oy - Jatkuvat palvelut

Payam C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote on 24.03.2010 12:42:48:

> > 
> 
> you need to set a cache key based on the hostname (or something  
> dynamic) else you will serve caches content as (index.HTML) from  
> site1 for site2 and site3… index requests
