Default_server catch all block not working

lockev3.0 nginx-forum at nginx.us
Wed Jan 25 15:39:46 UTC 2012


Ok as I started thinking later ....what for do I need proxy_set_header
if my intention is to not proxy to Apache any request fall onto this
catch all default_server  ?

To see my config let's say it is as follow (not all parameters to let it
be clearer):

======================    /etc/nginx/sites-enabled/mydomain
server {
        
        listen   80;                
        server_name mydomain.com www.mydomain.com sub1.mydomain.com
sub2.mydomain.com sub3.mydomain.com
        error_page  502 503 504 400 /50x.html;
        error_page  404  /404.php;

        large_client_header_buffers     4 4k;       

        location = /50x.html {
                root /var/www/mydomain/static/;
        }
        location ~* \.(jpg|jpeg|gif|png|css|bmp|ico|txt|html|swf)$ {   

                root /var/www/mydomain/
                expires 1y;
        }
          location / {
                proxy_pass         http://127.0.0.1:60080/;
                proxy_redirect     off;
             ........
          }      
}

So my goal is to define a new vhost so that all requests reaching my
nginx which don't fit any of my server names (all subdomains) are
responded as one of 2 ::  404 returned or forwarding to another external
URL (...whatever it fits better for SEO)

======================    /etc/nginx/sites-enabled/mydomain
server {
       listen 80 default_server;
        server_name  _;
        error_log       /var/log/nginx/000default-error.log error;
       location / {
               proxy_set_header Host $host;
               #return 404;
               rewrite .* http://doesnotexist.com permanent;
       }
}


I must say I tested (sure badly i did ) the proxy_set_header (not sure
what for in my case) and still the same behaviour .....all my clients
away :(

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,221572,221640#msg-221640



More information about the nginx mailing list