A catch-all and named server in a single configuration

Almir Karic almir at kiberpipa.org
Wed Jul 2 17:49:42 MSD 2008

On Wed, Jul 02, 2008 at 03:32:24PM +0200, Matthijs Langenberg wrote:
> Igor Sysoev wrote:
> > On Fri, Jun 13, 2008 at 12:37:59PM +0200, Matthijs Langenberg wrote:
> > 
> >> I want a directory listing for so I added another server entry:
> >> 
> >> 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;
> That setup doesn't work for me.
> When I add the "listen ip:port default;" directive for the catch-all 
> service, my dir listing stops working at all.
> Maybe I'm not making myself clear enough. I'm searching for setup that 
> for instance allows me to proxy all requests for all hosts, but also be 
> able to make an exception for a certain host.
> e.g. requests for '*' should be proxied to apache, except for a request 
> for 'exceptional_domain.com', which should be proxied to 
> http://mongrel-cluster.
> I'm aware that I'm running a somewhat old version of Nginx, have I ran 
> into a bug that already has been fixed?

you are doing something wrong, as that setup works without problems for
me. most of my sites are proxied back to apache, while some of them are
handled by nginx, example:

   server {
        listen default;
                location / {
                    proxy_max_temp_file_size 10M;
                    proxy_set_header   Host             $host;
                    proxy_set_header   X-Real-IP        $remote_addr;
                    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                    limit_conn   one  10;
        server {
            server_name break-festival.org www.break-festival.org break-festival.com www.break-festival.com;
            location / {
                fastcgi_pass   localhost:34003;
                include /etc/nginx/django-fcgi.conf;
                rewrite ^/favicon.ico$ /static/favicon.ico last;
            location /br-media {
                alias   /home/break/br/media;
            location /media {
                alias   /home/break/br/django/contrib/admin/media;
            location /admin-media {
                alias   /home/break/br/django/contrib/admin/media;
            access_log  /home/break/access.log;
            error_log  /home/break/error.log;

More information about the nginx mailing list