Running other vhosts beside the catc-all default vhost

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://:82$host;
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?

On Thu, 2010-06-17 at 16:41 +0200, Nedim Hadzimahmutovic wrote:

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

So Debian or Ubuntu…

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.

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 :wink:

Cliff

Hi Cliff,

I’m on Debian and nginx.conf says:

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

so I guess it is not important if my vhost files are named domain.com or
domain.com.conf, neither work because of the default server.

Nedim

a bit late but, could you tell me how? quite similar situation I have
(see my post at
Re: Default_server catch all block not working) but
desperately failing with all tested combinations !
please Nedim help

Posted at Nginx Forum:

Got it working…

On Tue, Jun 22, 2010 at 10:42 AM, Nedim Hadzimahmutovic <