Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to use nginx to switch between servers when an 500 error code is send as reply from an upstream server to a request from the client. How can this be done?

share|improve this question
You shouldn't be using a 500 status response as a basis for fencing a node unless this is purely a static content server. If you've got application code running, then it should be using something else (500 is far too generic) to indicate the node should be fenced). – symcbean Jun 1 '12 at 11:51
up vote 0 down vote accepted

Use *proxy_next_upstream* in location.

proxy_next_upstream http_500;

valid choices include: error|timeout|invalid_header|http_500|http_502|http_503|http_404 etc. Can be combined using space as a delimiter:

proxy_next_upstream timeout error http_500 <etc>;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.