I have an nginx setup which works very well.
I am using an upstream block to load balance between two servers.
These servers give HTTP 200 response even if they unable to serve the request, but they set custom http header like this:
When the response is OK, they give:
Is it possible to configure nginx to try next upstream server while the first one gives “X-Response-Status: Failed”?
I mean like following in nginx config:
proxy_next_upstream error timeout http_* ($sent_http_x_response_status="Failed")
I have to keep upstream servers giving HTTP 200 even on errors because there is an error message in http body in binary form.
I have to pass this binary error to client if none of upstream server are able to serve the request.
There’s no option for
proxy_next_upstream to implement the behavior you describe.
Your application should not return an
HTTP 200 if it couldn’t actually process the request. Have the application return a more appropriate error, such as
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.