15

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.

Raul Rene
  • 10,014
  • 9
  • 53
  • 75
  • Off topic. Try serverfault.com. – user207421 Feb 12 '13 at 09:26
  • 1
    I agree with you that it goes better in ServerFault, but there are Apache and mod_proxy related tags, are there not? My question targets the mod_proxy directive settings of Apache 2.2 Server. – Raul Rene Feb 12 '13 at 10:03
  • 3
    I know, thank you for that. I managed however to find a solution by my own and I'm adding it here, maybe someone finds it useful. – Raul Rene Feb 12 '13 at 12:20

1 Answers1

31

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
Raul Rene
  • 10,014
  • 9
  • 53
  • 75
  • What is that ProxyPreserveHost for ? To setting timeout ProxyTimeout Directive isn't enough !!!! Do we have to specify all these lines to setup ProxyTimeout ? – ArunRaj Feb 19 '15 at 03:20
  • 4
    Where are these lines added? – user230910 May 06 '17 at 07:04
  • The directive `ProxyTimeout` can be placed in: **server config** and under **virtual host**. Initial question was about all of the requests made, which means global scope (server config), thus I would put it to `/etc/apache2/mods-available/proxy.conf` or familiar file under Apache conf dir, to keep it in order. However, in practice, it can be placed anywhere. I would also wrapped it in `` to avoid a failure upon migration or module package removable. – Ilia Ross Aug 21 '20 at 12:48