# Running other vhosts beside the catc-all default vhost

**URL:** <https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319>\
**Category:** NGINX\
**Created:** [June 17, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319 "2010-06-17T16:42:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nedim\_Hadzimahmutov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nedim\_Hadzimahmutov](https://www.ruby-forum.com/u/Nedim_Hadzimahmutov)\
**Post date:** [June 17, 2010, 4:42pm UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319/1 "2010-06-17T16:42:58Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![Nedim\_Hadzimahmutov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nedim\_Hadzimahmutov](https://www.ruby-forum.com/u/Nedim_Hadzimahmutov)\
**Post date:** [June 17, 2010, 8:13pm UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319/2 "2010-06-17T20:13:51Z")

</div>

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 😉

Cliff

---

<div class="post-metadata">

**Author:** ![Nedim\_Hadzimahmutov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nedim\_Hadzimahmutov](https://www.ruby-forum.com/u/Nedim_Hadzimahmutov)\
**Post date:** [June 22, 2010, 10:51am UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319/3 "2010-06-22T10:51:08Z")

</div>

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](http://domain.com) or  
domain.com.conf, neither work because of the default server.

Nedim

---

<div class="post-metadata">

**Author:** ![Nedim\_Hadzimahmutov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nedim\_Hadzimahmutov](https://www.ruby-forum.com/u/Nedim_Hadzimahmutov)\
**Post date:** [January 25, 2012, 4:56pm UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319/4 "2012-01-25T16:56:15Z")

</div>

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](http://forum.nginx.org/read.php?2,221572,221640#msg-221640)) but  
desperately failing with all tested combinations !  
please Nedim help

Posted at Nginx Forum:

> **[Re: Running other vhosts beside the catc-all default vhost](https://forum.nginx.org/read.php?2,99440,221641#msg-221641)**
>
> 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 wil

---

<div class="post-metadata">

**Author:** ![Nedim\_Hadzimahmutov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@Nedim\_Hadzimahmutov](https://www.ruby-forum.com/u/Nedim_Hadzimahmutov)\
**Post date:** [June 22, 2010, 11:02am UTC](https://www.ruby-forum.com/t/running-other-vhosts-beside-the-catc-all-default-vhost/190319/5 "2010-06-22T11:02:51Z")

</div>

Got it working…

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