nginx gives 502 for non handled exception 500 error in flask
Finally I was able to solve this issue. Thanks to @Jeff Storey and @joppich.
My proxy server was not able to read the response from by backend server which was causing this issue. I added an interceptor to catch all exceptions and propagate it to NGINX via uwsgi using the nginx proxy_intercept_errors on;. Big thanks Jeff and joppich. Appreciate your help.
I am running a Flask application and using uwsgi socket nginx configuration.
This may be a stupid question but the issue I am facing is that whenever there is exception raised in Flask code (non handled exception for example 1/0), my nginx gives 502 instead of 500. I wanted to know if raising the exception is not getting propagated to nginx as 500 from uwsgi unix socket by default or do I need to specify this explicitly? Somewhere I read that for exceptions, Flask doesn't raise 500 error message automatically. Any comments will be helpful. Thanks.