A catch-all and named server in a single configuration

Igor Sysoev is at rambler-co.ru
Fri Jun 13 17:59:43 MSD 2008


On Fri, Jun 13, 2008 at 12:37:59PM +0200, Matthijs Langenberg wrote:

> I want to setup a catch-all server for all domains referred to that
> ip. (It should pass various domains to a rails app).
> Therefore I use:
> 
> server {
>   server_name _;
>   ## do some stuff
> }
> 
> Now I there is one exception for this, there is a special domain where
> I want a directory listing for so I added another server entry:
> 
> server {
>   server_name exceptional_domain.com
>   ## do some dir listing stuff
> }
> 
> server {
>   server_name _*;
>   ## do some stuff
> }
> 
> After restarting nginx, all domains where caught in the first entry,
> showing the dir listing! None of the domains hit rails anymore!
> I solved the problem by adding a conditions to the catch-all entry,
> which is pretty ugly when I want to add some additional vhosts, but
> it'll do for now.
> 
> Is this behavior a bug, or is it intended?
> 
> - Matt
> 
> p.s. this is nginx-0.4.13-2 on debian etch

The first server is default server for given ip:port pair.
You may explicitly set any server as default using the "default" keyword
in the listen directive:

     server {
         listen   ip:port default;


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list