Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.


Edit: I also tried using the mod_reqtimeout directive directly, but it did not do the trick for me:

LoadModule reqtimeout_module modules/mod_reqtimeout.so

RequestReadTimeout header=1200 body=1200
share|improve this question
    
The ProxyRequests directive should usually be set off when using ProxyPass. Open proxy servers are dangerous both to your network and to the Internet at large. –  user67717 Mar 21 '13 at 17:54

2 Answers 2

up vote 0 down vote accepted

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
share|improve this answer

According to the Apache documentation, if the ProxyTimeout configuration directive is not specified, the global/vhost setting of Timeout is used and in effect. So if the backend is taking longer than Timeout seconds, Apache will close the connection (!).

So even though ProxyTimeout has a default of 300s, you pretty much need to specify it anyway to make sure it is in effect.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.