Welcome! Log In Create A New Profile

Advanced

Running other vhosts beside the catc-all default vhost

Posted by grungy 
Running other vhosts beside the catc-all default vhost
May 18, 2010 05:30AM
I have a catchall default vhost, cat /etc/nginx/sites-available/default :

[code]
server {
listen 80 default;
server_name _;
server_name_in_redirect off;
resolver 127.0.0.1;
#### www. redirect - all domains starting with www will be redirected to http://domain. ####
if ($host ~* ^(www\.)(.+)) {
set $rawdomain $2;
rewrite ^/(.*)$ http://$rawdomain/$1 permanent;
}
access_log /var/log/ispconfig/httpd/$host/access.log;
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|html|htm|mp3)$ {
root /var/www/$host/web;
access_log off;
expires 30d;
}

location / {
root /var/www/$host/web;
index index.html index.htm index.php;
access_log off;
proxy_pass http://$host:82;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
[/code]



It works perfectly but I want to have other vhosts on the same server besides the default catchall one. If I add another server let's say in /etc/nginx/sites-available/domain.com Nginx will ignore it. But if I add that same server in /etc/nginx/sites-available/default before the catchall server then it work perfectly.

The problem is that it is not really practical to keep all the vhosts/servers in the same file.

Is there a way to make this work and not keep all the servers in /etc/nginx/sites-available/default file?
Re: Running other vhosts beside the catc-all default vhost
May 19, 2010 02:46PM
I have the same question. Haven't found anything thing that explicitly states how to do that. I'll be looking forward to seeing what people have to say. Thanks for posting this.
Re: Running other vhosts beside the catc-all default vhost
June 18, 2010 09:47AM
[quote="That's because the name should be sites-available/domain.com.conf. If you look in nginx.conf you'll see that it includes sites-available/*.conf, not *.com ;-) Cliff"]
[/quote]



Edited 1 time(s). Last edit at 06/18/2010 09:47AM by grungy.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready