Apache proxy caching "service temporarily unavailable" response when target is down

lostintranslation picture lostintranslation · Sep 6, 2013 · Viewed 8.7k times · Source

I have apache sitting in front of my node server. Node is running on certain port, I am using apache to proxy to that port and also have apache configured for https.

When I start apache and then start my node server everything runs great. If I bring down the node server and try to hit my service apache says 'Service Temporarily Unavailable'. This is expected as my node server is down.

However when I bring my server back up without touching apache and try to hit me service again apache still says 'Service Temporarily Unavailable'. Its like apache is not trying again. If I bounce apache all is well again.

Since I am running with forever there is a chance my server could be down for a few second if a fatal happens. I don't want to have to bounce apache if that happens.

Is there anyway to get apache to always try and not cache the fact that a Service it recently tried to hit was unavailable?

Answer

moka picture moka · Sep 6, 2013

You need to add retry=0 to ProxyPass directive. So it will be something like:

ProxyPass /example http://backend.example.com retry=0

Check some info here: http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass