Welcome! Log In Create A New Profile

Advanced

Unexpected error response

October 17, 2010 08:32PM
I'm using Nginx as a front end proxy and have some config that checks for a file called /maintenance.html and shows that if it's present.

As our app is quite Ajaxy I would like return a 503 status when the /maintenance.html page is served up so that the client app can do some smarts to make things a bit more friendly for the end user.

This is the config that I currently have:

[code]
recursive_error_pages on;

location / {
return 503;
error_page 503 @tryMaintenance;
}

location @tryMaintenance {
try_files /maintenance.html /tomcat_stopped.html @resetResposeCodeAndForwardToRevolve;
}
location @resetResposeCodeAndForwardToRevolve {
return 400;
error_page 400 = @forwardToRevolve;
}

location @forwardToRevolve {
proxy_pass http://revolve:2080;
error_page 502 504 @serverDown;
}

location @serverDown {
rewrite .* /server_down.html;
}
[/code]

However when the maintenance.html file is not present I end up getting the generic Nginx 503 error rather than the request getting forwarded on to my backend server as I expected.

So I guess my question is - is this a bug or am I simply pushing the boundaries of what is possible using error_page as a flow control mechanism?

As an aside if I modify the location @tryMaintenance to the following, the config does work even though they are basically the same.

[code]
location @tryMaintenance {
try_files /maintenance.html /tomcat_stopped.html =400;
error_page 400 = @forwardToRevolve;
}
[/code]

Thanks

Oliver
Subject Author Posted

Unexpected error response

hutchiko October 17, 2010 08:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready