On 25 Jan 2012 15h39 WET, nginx-forum@nginx.us wrote:
> 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;
> }
> }
This can be made much simpler:
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/000default-error.log error;
return 301 http://doesnotexist.com;
}
This redirects to a new host.
For returning a 404 just do:
return 404;
I think that 444 is preferable. No business trying to access a host
that doesn't exist. But it's up to you.
Enable the debug log and set:
proxy_intercept_errors on;
Trace the requests and see how are the 503s generated.
http://nginx.org/en/docs/debugging_log.html
--- appa
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx