Running other vhosts beside the catc-all default vhost

Nedim Hadzimahmutovic nedim at hadzimahmutovic.com
Thu Jun 17 18:41:28 MSD 2010


I have a catchall default vhost, cat /etc/nginx/sites-available/default :



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;
}
}

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100617/0eafafc7/attachment.html>


More information about the nginx mailing list