You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Christian Folini <ch...@post.ch> on 2007/09/27 10:09:05 UTC

[users@httpd] Reverse Proxy Timeout

Hello,

Back in March 2007, there was a report on unexpected behaviour of
timeout settings in a reverse proxy setup:

http://mail-archives.apache.org/mod_mbox/httpd-users/200703.mbox/%3cd3e73af70703220059o724eb0f3td53b313fa18d207f@mail.gmail.com%3e

I have stumbled over the same issue one of these days and
it is bugging me.

I am working with apache 2.0.61 in prefork mode. There is a client
(netcat) connecting to the apache reverse proxy. Then apache
connects to a backend running netcat in listen mode. 

The config and the test runs:

client:
  nc localhost 80 < /tmp/get-request

apache config (stripped down test config):
  Timeout		10
  <VirtualHost *:80>
    Timeout		20
    ProxyPass	/	http://127.0.0.1:8080/
    ProxyTimeout	30
  </Virtualhost>

backend application:
  nc -l -p 8080
  -> output:
     GET / HTTP/1.1
     Host: 127.0.0.1:8080
     Max-Forwards: 10
     X-Forwarded-For: 127.0.0.1
     X-Forwarded-Host: testhost
     X-Forwarded-Server: testhost.myhome.net


When the backend is not reacting, apache interrupts the
connection and issues a "502 Proxy Error" to the client, which
is the expected behaviour. The problem is the timeout.

There are three timeout values configured above. A global server
one, a virtual host timeout and a ProxyTimeout statement.

One would expect that ProxyTimeout is in charge here.
(See http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxytimeout
for example)

But in fact, the virtual host timeout is taken (-> 20 seconds).
See my tcpdump output:

tcpdump -i lo  port 80:
...
09:56:03.010405 IP localhost.44761 > localhost.www: S 2165749057:2165749057(0) win 32792 <mss 16396,sackOK,timestamp 214957352 0,nop,wscale 7>
09:56:03.010560 IP localhost.www > localhost.44761: S 2167281898:2167281898(0) ack 2165749058 win 32768 <mss 16396,sackOK,timestamp 214957352 214957352,nop,wscale 7>
09:56:03.010412 IP localhost.44761 > localhost.www: . ack 1 win 257 <nop,nop,timestamp 214957352 214957352>
09:56:03.010441 IP localhost.44761 > localhost.www: P 1:31(30) ack 1 win 257 <nop,nop,timestamp 214957352 214957352>
09:56:03.010449 IP localhost.www > localhost.44761: . ack 31 win 256 <nop,nop,timestamp 214957352 214957352>
09:56:23.008039 IP localhost.www > localhost.44761: P 1:530(529) ack 31 win 256 <nop,nop,timestamp 214962352 214957352>
09:56:23.008049 IP localhost.44761 > localhost.www: . ack 530 win 265 <nop,nop,timestamp 214962352 214962352>
09:56:23.008102 IP localhost.www > localhost.44761: F 530:530(0) ack 31 win 256 <nop,nop,timestamp 214962352 214962352>
09:56:23.008150 IP localhost.44761 > localhost.www: F 31:31(0) ack 531 win 265 <nop,nop,timestamp 214962352 214962352>
09:56:23.008162 IP localhost.www > localhost.44761: . ack 32 win 256 <nop,nop,timestamp 214962352 214962352>


This is 20 seconds after the connection to the backend and not
thirty seconds as issued by ProxyTimeout.

It seems as if ProxyTimeout would only affect forward proxy setups and not
reverse proxy configurations. Unfortunately, the documentation addresses
all proxy requests.

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxytimeout :
> This directive allows a user to specifiy a timeout on proxy requests. 
> This is useful when you have a slow/buggy appserver which hangs, 
> and you would rather just return a timeout and fail gracefully 
> instead of waiting however long it takes the server to return.

And in fact, the explanation of the Timeout directive in the core 
documentation does cover this either:

http://httpd.apache.org/docs/2.0/mod/core.html#timeout :

> The TimeOut directive currently defines the amount of time Apache will wait for three things:
> 
>   1. The total amount of time it takes to receive a GET request.
>   2. The amount of time between receipt of TCP packets on a POST or PUT request.
>   3. The amount of time between ACKs on transmissions of TCP packets in responses.

Could somebody please confirm this? I am not sure wether this is
an unexpected behaviour, an undocumented feature, a bug or a
misconfiguration on my behalf.

Any comment is appreciated.

Christian Folini



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org