This behavior could be accomplished too by apache in two ways
First one, using failonstatus
The directive is failonstatus in the module mod_proxy
For example, I used to use the below configuration for a productive environment
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED <Proxy "balancer://mycluster"> BalancerMember "https://bod_node3.wavin.com:8443" route=1 connectiontimeout=5 keepalive=On retry=1200 BalancerMember "https://bod.wavin.com:9443" route=2 connectiontimeout=5 keepalive=On retry=1200 ProxySet stickysession=ROUTEID ProxySet lbmethod=bytraffic ProxySet failonstatus=500,503,502 </Proxy>
Second way, and in my opinion the best option is to use the module mod_proxy_hcheck https://httpd.apache.org/docs/2.4/mod/mod_proxy_hcheck.html
Currently, I am using this module to detect backend issues
LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so LoadModule watchdog_module modules/mod_watchdog.so ... ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid <Proxy "balancer://mycluster"> BalancerMember "https://bod_node3.wavin.com:8443" route=node3 connectiontimeout=5 keepalive=On retry=1200 hcmethod=GET hcuri=/BOE/CMC/ BalancerMember "https://bod.wavin.com:9443" route=node4 connectiontimeout=5 keepalive=On retry=1200 hcmethod=GET hcuri=/BOE/CMC/ ProxySet lbmethod=bytraffic </Proxy>