7

I have an Apache httpd web server running mod_proxy and mod_proxy_balancer. The whole of /somedir is sent to 2 worker machines which service the requests using the round robin scheduler. Each worker machine is running IIS but I don't think that is important.

I can demonstrate the load balancer working by repeatedly requesting a single page which contains the IP address of the machine and can see that it switches from one to the other in a predictable round robin fashion.

If I switch off one of the IIS servers and start requesting the same page then each page only contains the IP address of the machine that is up. However, if I start IIS and don't run my IIS application then /somedir returns 500 (as it should).

I've added 500 to the failonstatus (Apache 2.4) so when it hits the error Apache places the worker machine into error state. Apache still returns the proxy error to the client though. How can I make Apache catch the proxy failure and retry using a different worker in the same way that a connection failure does.

Update

There is almost the same question asked in StackOverflow so joining them together.

https://stackoverflow.com/questions/11083707/httpd-mod-proxy-balancer-failover-failonstatus-transperant-switching

David Newcomb
  • 263
  • 5
  • 14
  • 1
    Verify that the HTTP response code on the error page is truly 500 - some configurations will kick back an error page that says "500 error!" but with an `HTTP 200 OK` response code. – Shane Madden Aug 04 '12 at 20:16
  • I'm running the command in telnet and I definitely get "HTTP/1.1 500 Internal Server Error" in the HTTP response header. – David Newcomb Aug 06 '12 at 13:11

2 Answers2

4

I have spoken to a Dev on httpd mailing list and he confirmed that this feature has not been implemented in the current code base. I have also reviewed the code myself. The state machine inside mod_proxy_balancer cannot retry on HTTP error but can only do so in case of connection error. I tried to implement it myself but its too complicated and I can easily make the code base unstable.

So this problem has no known solution today...

Praveen
  • 191
  • 1
  • 5
  • 2
    I found your questions in the httpd dev list! which is why I was asking here. I looked at the code myself and it shows that by the time you get to the 500 error you are out of the retry mechanism. httpd-dev said they would try to implement it when they have time, but there's no plan to. – David Newcomb Aug 14 '12 at 10:34
0

Just in case someone reach this question again: the failonstatus directive was implemented since Apache 2.2.27.

<Proxy balancer://backends>
BalancerMember http://10.1.1.11
BalancerMember http://10.1.1.12
ProxySet failonstatus=500
</Proxy>

Log:

[Thu Apr 28 03:13:06.176916 2016] [proxy_balancer:error] [pid 3285:tid 140231873353472] [client 10.1.1.1:43608] AH01174: balancer://puppetmaster: Forcing worker (http://10.1.1.12) into error state due to status code 500 matching 'failonstatus' balancer parameter
hajimuz
  • 111
  • 3