Setting timeout for all the ProxyPass mappings in Apache Server mod_proxy directive

Raul Rene picture Raul Rene · Feb 12, 2013 · Viewed 76.4k times · Source

What I have and works:

I'm using Apache HTTPD 2.2 for proxy requests. I have multiple ProxyPass mappings:

ProxyRequests On 
<Proxy *>
AddDefaultCharset off
    Order deny,allow
    Allow from all
</Proxy>
ProxyPreserveHost Off

ProxyPass /a http://some_ip/
ProxyPassReverse /a http://some_ip/

ProxyPass /b http://some_other_ip/
ProxyPassReverse /b http://some_other_ip/

...

This works well.

What I want:

Some of my requests are taking longer, so they timed out giving me a Proxy Error - Reason: Error reading from remote server.

I want to set timeout for all of my requests. Can I do this without having to add timeout=... KeepAlive=On for every ProxyPass mapping?

I currently have something like:

ProxyPass /a http://some_ip/ timeout=1200 KeepAlive=On
ProxyPassReverse /a http://some_ip/

ProxyPass /b http://some_other_ip/ timeout=1200 KeepAlive=On
ProxyPassReverse /b http://some_other_ip/

... and i do this for all my ProxyPass mappings

Can I tell Apache in some way to add timeout and KeepAlive parameters for all the mappings? Thanks in advance.

Answer

Raul Rene picture Raul Rene · Feb 12, 2013

I've managed to find a solution by my own. You can set the timeout using directly the ProxyTimeout directive of mod_proxy :

ProxyRequests On 
<Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
</Proxy>
ProxyPreserveHost Off

ProxyTimeout 1200