# Trouble with VHosts

**URL:** <https://www.ruby-forum.com/t/trouble-with-vhosts/178556>\
**Category:** NGINX\
**Created:** [November 6, 2009, 12:20pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556 "2009-11-06T12:20:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 12:20pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/1 "2009-11-06T12:20:26Z")

</div>

Hello,

As helpful and nice people in this mailing list seem to ignore my  
previous message, let’s try to ask about a different problem. 🙂

nginx 0.8.22  
– configure options:  
./configure --prefix=/u01/nginx  
–http-log-path=/var/log/nginx-access.log   
–http-client-body-temp-path=/u02/nginx-client-temp   
–http-proxy-temp-path=/u02/nginx-proxy-temp   
–http-fastcgi-temp-path=/u02/nginx-fcgi-temp   
–error-log-path=/var/log/nginx-error.log   
–pid-path=/var/run/nginx.pid

VHosts trouble. Supposed to be:

[_] (www.)[site.com](http://site.com) → proxied to local Apache at 8181  
[_] [bs.site.com](http://bs.site.com) → proxied to local Apache at 8282

Does not work, always proxies to 8181.

## I’ve tried like a gazillion of configurations, here’s the latest one:

# ==================================

# UPSTREAMS

# ==================================

upstream main {  
server localhost:8181;  
}

upstream bs {  
server localhost:8282;  
}

# ==================================

# BANNERS

# ==================================

server {  
listen 80;  
server\_name [bs.site.com](http://bs.site.com);

location / {  
proxy\_redirect off;  
proxy\_pass [http://bs/](http://bs/);  
}

error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /u01/nginx/html;  
}

location ~ /.ht {  
deny all;  
}

include /u01/nginx/conf/proxy.conf;  
}

# ==================================

# MAIN SITE

# ==================================

proxy\_cache\_path /u02/nginx-cache-one levels=1:2 keys\_zone=one:16m  
max\_size=100m;  
proxy\_temp\_path /u02/nginx-temp;

server {  
listen 80;  
server\_name [site.com](http://site.com) [www.site.com](http://www.site.com);

location /i/ {  
root /u01/web/site.com/www-root/i;  
access\_log off;  
expires 1d;  
}

location /get/ {  
proxy\_redirect off;  
proxy\_cache one;  
proxy\_cache\_valid 30s;  
proxy\_pass [http://main/](http://main/);  
}

location /torrent/ {  
proxy\_redirect off;  
proxy\_cache off;  
proxy\_pass [http://main/](http://main/);  
}

location / {  
proxy\_cache one;  
proxy\_cache\_valid 2m;  
proxy\_redirect off;  
proxy\_pass [http://main/](http://main/);  
}

error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root /u01/nginx/html;  
}

location ~ /.ht {  
deny all;  
}

## include /u01/nginx/conf/proxy.conf; }

/u01/nginx/conf/proxy.conf;

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\_set\_header X-Host $host;  
client\_max\_body\_size 10m;  
client\_body\_buffer\_size 128k;  
proxy\_connect\_timeout 30;  
proxy\_send\_timeout 30;  
proxy\_read\_timeout 30;  
proxy\_buffer\_size 4k;  
proxy\_buffers 4 32k;  
proxy\_busy\_buffers\_size 64k;  
proxy\_temp\_file\_write\_size 64k;

* * *

nginx.conf:

user nobody nogroup;  
worker\_processes 2;

events {  
worker\_connections 1024;  
use epoll;  
}

http {  
server\_name\_in\_redirect off;  
server\_tokens off;

```
include mime.types;
default_type application/octet-stream;

sendfile on;
gzip on;
gzip_min_length 1024;
gzip_types 

```

text/plain,text/html,application/xml,application/json,application/vnd.php.serialized,text/xml,application/rss;

```
output_buffers 1 32k;
postpone_output 1460;

tcp_nopush on;
tcp_nodelay on;

keepalive_timeout 60;

include /u01/web/*.conf;

```

}

* * *

Please help, I’m on the edge of killing myself. 🙂

–  
Pavel

Posted at Nginx Forum:

> **[Trouble with VHosts](https://forum.nginx.org/read.php?2,20567,20567#msg-20567)**
>
> Hello, As helpful and nice people in this mailing list seem to ignore my previous message, let's try to ask about a different problem. :-) nginx 0.8.22 -- configure options: \[code\]./configure --prefix=/u01/nginx...

---

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 1:04pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/2 "2009-11-06T13:04:55Z")

</div>

i have no experience, and i’m newbie, but based on

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

if your configuration in i don’t know where:  
upstream main {  
server localhost:8181;  
}  
upstream bs {  
server localhost:8282;  
}

i guess that you should make 2 file in sites-available containing:  
server {  
listen 80;  
server\_name [site.com](http://site.com) [www.site.com](http://www.site.com);  
location / {  
proxy\_pass [http://main](http://main)  
}  
}  
and:  
server {  
listen 80;  
server\_name [bs.site.com](http://bs.site.com);  
location / {  
proxy\_pass [http://bs](http://bs)  
}  
}

maybe ^^, i don’t know yet, would you like to try it?

> Please help, I’m on the edge of killing myself. 🙂
> 
> –  
> Pavel

i will pray for you ^^  
Regards,  
GB

---

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 1:13pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/3 "2009-11-06T13:13:06Z")

</div>

Hello,

Thanks for the reply. I don’t get really what you’re proposing - there  
are 2 server{} elements for VHosts in main config file.

–  
Pavel

Posted at Nginx Forum:

> **[Re: Trouble with VHosts](https://forum.nginx.org/read.php?2,20567,20576#msg-20576)**
>
> Hello, As helpful and nice people in this mailing list seem to ignore my previous message, let's try to ask about a different problem. :-) nginx 0.8.22 -- configure options: \[code\]./configure --prefix=/u01/nginx...

---

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 2:02pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/4 "2009-11-06T14:02:16Z")

</div>

On Fri, Nov 6, 2009 at 6:08 PM, grmbl [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Please help, I’m on the edge of killing myself. 🙂

a debug log usually helps (–with-debug, error\_log /path/to/error.log  
debug;)

---

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/5 "2009-11-06T13:52:19Z")

</div>

oic, i’m sorry, after i reread your mail, my proposal was already like  
your configuration ^^,  
hmm…  
what happened if you remove the [site.com](http://site.com) ?  
and what happened if you remove the trailing slash [http://main/](http://main/); into  
[http://main](http://main); ?

Regards,  
GB

---

<div class="post-metadata">

**Author:** ![grmbl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8edcca/32.png) [@grmbl](https://www.ruby-forum.com/u/grmbl)\
**Post date:** [November 6, 2009, 4:50pm UTC](https://www.ruby-forum.com/t/trouble-with-vhosts/178556/6 "2009-11-06T16:50:15Z")

</div>

I’ve found the cause.

In gzip\_types I’ve had types listed with comma inbetween, while they  
should be with space.

What’s weird that configs got parsed partially - stuff seem to be  
working except for quirks like this.

Posted at Nginx Forum:

> **[Re: Trouble with VHosts](https://forum.nginx.org/read.php?2,20567,20650#msg-20650)**
>
> Hello, As helpful and nice people in this mailing list seem to ignore my previous message, let's try to ask about a different problem. :-) nginx 0.8.22 -- configure options: \[code\]./configure --prefix=/u01/nginx...
