Mark upstream proxy inoperable based on response body or arbitrary http status?


I just started playing with Nginx. My goal is to rate limit requests to
a set of backend proxies, and it looks like I want to do this using the
modules HttpUpstreamModule, HttpProxyModule, and HttpLimitReqModule

I see that HttpUpstreamModule marks an upstream server as inoperable
based on the setting of proxy_next_upstream. However, I need to be able
to mark a server as inoperable given conditions that I don’t appear to
be able to set. Specifically, if I could examine the results of a server
response and mark it inoperable, or operable, based on the contents,
that’d be best. Another, possibly less complicated solution would be for
me to mark a server inoperable if the http status in the response is
302, but I don’t see a “http_302” for proxy_next_upstream.

It would also be great if the amount of time before re-checking a server
marked as inoperable was configurable separate from HttpUpstreamModule’s
fail_timeout (so I could say something like, if a server fails once in 1
second mark it inoperable, but don’t try to check it again for 3

Am I overlooking options to do what I want to do here?


Posted at Nginx Forum:,229472,229472#msg-229472

I tried playing with proxy_intercept_errors and error_page to change
302s to 500s, then added http_500 to proxy_next_upstream, but this
doesn’t seem to mark a proxy as down. I assume as far as
HttpUpstreamModule is concerned, the response is a 302, prior to it
being converted to a 500 (?).


Posted at Nginx Forum:,229472,229487#msg-229487

I did something I am sure is terrible and hacked up the source so that I
could use http_302 along with proxy_next_upstream. This appears to do
what I want, though now I am not sure that HttpLimitReqModule can
actually do what I need.


Posted at Nginx Forum:,229472,229489#msg-229489