Trouble with VHosts

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. :slight_smile:

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 → proxied to local Apache at 8181
[
] 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;

location / {
proxy_redirect off;
proxy_pass 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 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/;
}

location /torrent/ {
proxy_redirect off;
proxy_cache off;
proxy_pass http://main/;
}

location / {
proxy_cache one;
proxy_cache_valid 2m;
proxy_redirect off;
proxy_pass 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. :slight_smile:


Pavel

Posted at Nginx Forum:

i have no experience, and i’m newbie, but based on
http://wiki.nginx.org/NginxHttpUpstreamModule

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 www.site.com;
location / {
proxy_pass http://main
}
}
and:
server {
listen 80;
server_name bs.site.com;
location / {
proxy_pass http://bs
}
}

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

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


Pavel

i will pray for you ^^
Regards,
GB

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:

On Fri, Nov 6, 2009 at 6:08 PM, grmbl [email protected] wrote:

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

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

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 ?
and what happened if you remove the trailing slash http://main/; into
http://main; ?

Regards,
GB

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: