Configure mod_proxy to use different parameters based on HTTP Method

apache-2.2failoverload balancingmod-proxy

I'm using mod_proxy as a failover proxy with two balance members.

While mod_proxy marks dead nodes as dead, it still routes one request per minute to each dead node and, if it's still dead, will either return 503 to the client (if maxattempts=0) or retry on another node (if it's > 0).

The backends are serving a REST web service. Currently I have set maxattempts=0 because I don't want to retry POSTs and DELETEs. This means that when one node is dead, each minute a random client will receive a 503. Unfortunately, most of our clients are interpreting codes like 503 as "everything is dead" rather than "that didnt work but please try that again".

In order to program some kind of automatic retry for safe requests at the proxy layer, I'd like to configure mod_proxy to use maxattempts=1 for GET and HEAD requests and maxattempts=0 for all other HTTP Methods.

Is this possible? (And how? 🙂

Best Answer

I think you may be out of luck -- as far as I can tell, the "obvious" way of doing this (with a <Limit> block) only works for access-control-related operations; I suspect it won't be doable.

In general, though, I don't think this is going to achieve what you think you want to achieve. In my experience, you normally actually want to do the opposite of what you've described; retrying non-idempotent requests against multiple backends is usually a bad idea (just in case they did the operation but didn't report success); you're far better off just failing everything out quickly and having the browser handle the retry if required.

Related Topic