António P. P. Almeida
January 25, 2012 11:18AM
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
Subject Author Posted

Default_server catch all block not working

lockev3.0 January 24, 2012 10:26AM

Re: Default_server catch all block not working

António P. P. Almeida January 24, 2012 10:36AM

Re: Default_server catch all block not working

Mit Rowe January 24, 2012 11:52AM

Re: Default_server catch all block not working

lockev3.0 January 24, 2012 12:57PM

Re: Default_server catch all block not working

lockev3.0 February 02, 2012 07:10AM

Re: Default_server catch all block not working

António P. P. Almeida January 24, 2012 02:52PM

Re: Default_server catch all block not working

lockev3.0 January 25, 2012 09:50AM

Re: Default_server catch all block not working

lockev3.0 January 25, 2012 10:39AM

Re: Default_server catch all block not working

lockev3.0 February 01, 2012 06:32AM

Re: Default_server catch all block not working

António P. P. Almeida January 25, 2012 11:18AM

Re: Default_server catch all block not working

lockev3.0 March 22, 2012 12:32PM

Re: Default_server catch all block not working

lockev3.0 March 28, 2012 04:11AM

Re: Default_server catch all block not working

Jonathan Matthews March 28, 2012 12:12PM

Re: Default_server catch all block not working

lockev3.0 April 16, 2012 04:43AM

Re: Default_server catch all block not working

Maxim Dounin April 19, 2012 08:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready