Welcome! Log In Create A New Profile

Advanced

Re: How to handle 500 Error on upstream itself, While Nginx handle other 5xx errors

Maxim Dounin
July 10, 2017 08:20AM
Hello!

On Fri, Jul 07, 2017 at 04:39:47PM +0300, ender ulusoy wrote:

> We have a NGINX reverse proxy (clustered) with 45 upstreams (22 domains, 20
> subdomains, 11 apps).
>
> Some of our projects hosts apis for some users globally.
>
> Our developers designed special custom 500 responses for special cases and
> want to show that messages only for tomcat_api upstream.
>
> They want to serve 500 pages and handle exceptions on tomcat_api upstream
> members not on NGINX. But we want to handle all other 5xx errors on NGINX.
>
> As I can not succeeded need a hand right now.

Errors interception in the proxy module works as follows:

- Errors are only intercepted if proxy_intercept_errors is set to
"on", see http://nginx.org/r/proxy_intercept_errors. When
errors are not intercepted, all errors returned by upstream are sent
to the client as is.

- With "proxy_intercept_errors on", nginx will only intercept
errors with error_page configured.

That is, if you want to intercept all 5xx errors but not 500,
consider configuration like this:

proxy_pass ...
proxy_intercept_errors on;
error_page 501 502 503 504 505 /errors/5xx.html;

This will intercept all 5xx errors except 500.

For more information, see the documentation of the directives here:

http://nginx.org/r/proxy_intercept_errors
http://nginx.org/r/error_page

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to handle 500 Error on upstream itself, While Nginx handle other 5xx errors

ender ulusoy July 07, 2017 09:42AM

Re: How to handle 500 Error on upstream itself, While Nginx handle other 5xx errors

Maxim Dounin July 10, 2017 08:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 131
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