You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rainer Jung <ra...@kippdata.de> on 2010/08/05 11:50:54 UTC
Changing Connection header use in forward proxy
It seems the forward proxy by default sets "Connection: Keep-Alive"
although it later closes the connection when it detects
is_address_reusable == 1 in the worker.
Doesn't it make sense to issue "Connection close" instead?
Since this happens in the code where we have a connection and a request,
but no worker struct available, is it safe to apply this whenever
proxyreq is PROXYREQ_PROXY? Or can one somehow configure a non-default
forward worker with an explicit URL to e.g. a frequently used origin
server which would then be expected to reuse connections? I don't expect
that to be posible, but I'm not sure.
Regards,
Rainer
RE: Changing Connection header use in forward proxy
Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
> -----Original Message-----
> From: Ryujiro Shibuya
> Sent: Freitag, 13. August 2010 05:14
> To: dev@httpd.apache.org
> Subject: RE: Changing Connection header use in forward proxy
>
> >
> > How about the following untested patch instead?
> >
> > Index: modules/proxy/proxy_util.c
> > ===================================================================
> > --- modules/proxy/proxy_util.c (revision 982130)
> > +++ modules/proxy/proxy_util.c (working copy)
> > @@ -1568,6 +1568,7 @@
> > *balancer = NULL;
> > *worker = conf->forward;
> > access_status = OK;
> > + apr_table_set(r->subprocess_env,
> "proxy-nokeepalive",
> > "1");
> > }
> > }
> > else if (r->proxyreq == PROXYREQ_REVERSE) {
> > @@ -1578,6 +1579,7 @@
> > *balancer = NULL;
> > *worker = conf->reverse;
> > access_status = OK;
> > + apr_table_set(r->subprocess_env,
> "proxy-nokeepalive",
> > "1");
> > }
> > }
> > }
> >
> > Regards
> >
> > Rüdiger
>
> Hi Rüdiger,
>
> I've applied this patch on 2.2.16 and tested. As the result,
> the appropriate
> "Connection" header is now sent to the origin server, as expected.
> For the usual forward proxy requests, "Connection: close"
> header is set.
> For the forward proxy requests for the origin server
> individually defined as
> "ProxySet keepalive=on", "Connection: Keep-Alive" header is set.
Commited as r985112
http://svn.apache.org/viewvc?rev=985112&view=rev
Regards
Rüdiger
RE: Changing Connection header use in forward proxy
Posted by Ryujiro Shibuya <rs...@gmail.com>.
> -----Original Message-----
> From: "Plüm, Rüdiger, VF-Group" [mailto:ruediger.pluem@vodafone.com]
> Sent: Thursday, August 05, 2010 8:03 PM
> To: dev@httpd.apache.org
> Subject: RE: Changing Connection header use in forward proxy
>
>
>
> > -----Original Message-----
> > From: Rainer Jung
> > Sent: Donnerstag, 5. August 2010 11:51
> > To: dev@httpd.apache.org
> > Subject: Changing Connection header use in forward proxy
> >
> > It seems the forward proxy by default sets "Connection: Keep-Alive"
> > although it later closes the connection when it detects
> > is_address_reusable == 1 in the worker.
> >
> > Doesn't it make sense to issue "Connection close" instead?
> >
> > Since this happens in the code where we have a connection and
> > a request,
> > but no worker struct available, is it safe to apply this whenever
> > proxyreq is PROXYREQ_PROXY? Or can one somehow configure a
> > non-default
> > forward worker with an explicit URL to e.g. a frequently used origin
> > server which would then be expected to reuse connections? I
> > don't expect
> > that to be posible, but I'm not sure.
>
> I haven't tried so far, but IMHO it should be possible to setup
> pooled connections for frequently used targets of a forward proxy
> by adding
>
> <Proxy http://www.frequentlyused.com/>
> # Set an arbitrary parameter to trigger the creation of a worker
> ProxySet keepalive=on
> </Proxy>
>
> If I am correct with this assumption the we should not proceed the way
> you proposed.
>
> How about the following untested patch instead?
>
> Index: modules/proxy/proxy_util.c
> ===================================================================
> --- modules/proxy/proxy_util.c (revision 982130)
> +++ modules/proxy/proxy_util.c (working copy)
> @@ -1568,6 +1568,7 @@
> *balancer = NULL;
> *worker = conf->forward;
> access_status = OK;
> + apr_table_set(r->subprocess_env, "proxy-nokeepalive",
> "1");
> }
> }
> else if (r->proxyreq == PROXYREQ_REVERSE) {
> @@ -1578,6 +1579,7 @@
> *balancer = NULL;
> *worker = conf->reverse;
> access_status = OK;
> + apr_table_set(r->subprocess_env, "proxy-nokeepalive",
> "1");
> }
> }
> }
>
> Regards
>
> Rüdiger
Hi Rüdiger,
I've applied this patch on 2.2.16 and tested. As the result, the appropriate
"Connection" header is now sent to the origin server, as expected.
For the usual forward proxy requests, "Connection: close" header is set.
For the forward proxy requests for the origin server individually defined as
"ProxySet keepalive=on", "Connection: Keep-Alive" header is set.
I feel it's a kind of pity that the origin server keep-alive is not fully
provided to general forward proxy requests, but anyway I'm glad that the
"Connection" header becomes consistent to the actual behavior. Thanks!
Regards,
Shibuya
Re: Changing Connection header use in forward proxy
Posted by Rainer Jung <ra...@kippdata.de>.
On 05.08.2010 13:03, "Plüm, Rüdiger, VF-Group" wrote:
>> -----Original Message-----
>> From: Rainer Jung
>> Sent: Donnerstag, 5. August 2010 11:51
>> To: dev@httpd.apache.org
>> Subject: Changing Connection header use in forward proxy
>>
>> It seems the forward proxy by default sets "Connection: Keep-Alive"
>> although it later closes the connection when it detects
>> is_address_reusable == 1 in the worker.
>>
>> Doesn't it make sense to issue "Connection close" instead?
>>
>> Since this happens in the code where we have a connection and
>> a request,
>> but no worker struct available, is it safe to apply this whenever
>> proxyreq is PROXYREQ_PROXY? Or can one somehow configure a
>> non-default
>> forward worker with an explicit URL to e.g. a frequently used origin
>> server which would then be expected to reuse connections? I
>> don't expect
>> that to be posible, but I'm not sure.
>
> I haven't tried so far, but IMHO it should be possible to setup
> pooled connections for frequently used targets of a forward proxy
> by adding
>
> <Proxy http://www.frequentlyused.com/>
> # Set an arbitrary parameter to trigger the creation of a worker
> ProxySet keepalive=on
> </Proxy>
Actually after staring at the code for a while IMHO there is no
difference between a forward or a reverse worker. There's only a default
forward and a default reverse worker and then additional workers as
configured.
It does make a difference whether a request is handled in forward or
reverse mode, but that is independent of workers.
You can define a worker originally meant for reverse use like in
ProxyPass /something http://www.origin.com
and allow forward mode
ProxyRequests On
If you then send
GET http://www.origin.com/ HTTP/1.0
your request will be handled by the worker defined through the above
ProxyPass (including pooling etc.). So "forward worker" or "reverse
worker" only makes sense for those builtin default workers (which are
kind of fallback and not configurable).
> If I am correct with this assumption the we should not proceed the way
> you proposed.
>
> How about the following untested patch instead?
>
> Index: modules/proxy/proxy_util.c
> ===================================================================
> --- modules/proxy/proxy_util.c (revision 982130)
> +++ modules/proxy/proxy_util.c (working copy)
> @@ -1568,6 +1568,7 @@
> *balancer = NULL;
> *worker = conf->forward;
> access_status = OK;
> + apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
> }
> }
> else if (r->proxyreq == PROXYREQ_REVERSE) {
> @@ -1578,6 +1579,7 @@
> *balancer = NULL;
> *worker = conf->reverse;
> access_status = OK;
> + apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
> }
> }
> }
Thanks, looks good, will test.
Regards,
Rainer
RE: Changing Connection header use in forward proxy
Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
> -----Original Message-----
> From: Rainer Jung
> Sent: Donnerstag, 5. August 2010 11:51
> To: dev@httpd.apache.org
> Subject: Changing Connection header use in forward proxy
>
> It seems the forward proxy by default sets "Connection: Keep-Alive"
> although it later closes the connection when it detects
> is_address_reusable == 1 in the worker.
>
> Doesn't it make sense to issue "Connection close" instead?
>
> Since this happens in the code where we have a connection and
> a request,
> but no worker struct available, is it safe to apply this whenever
> proxyreq is PROXYREQ_PROXY? Or can one somehow configure a
> non-default
> forward worker with an explicit URL to e.g. a frequently used origin
> server which would then be expected to reuse connections? I
> don't expect
> that to be posible, but I'm not sure.
I haven't tried so far, but IMHO it should be possible to setup
pooled connections for frequently used targets of a forward proxy
by adding
<Proxy http://www.frequentlyused.com/>
# Set an arbitrary parameter to trigger the creation of a worker
ProxySet keepalive=on
</Proxy>
If I am correct with this assumption the we should not proceed the way
you proposed.
How about the following untested patch instead?
Index: modules/proxy/proxy_util.c
===================================================================
--- modules/proxy/proxy_util.c (revision 982130)
+++ modules/proxy/proxy_util.c (working copy)
@@ -1568,6 +1568,7 @@
*balancer = NULL;
*worker = conf->forward;
access_status = OK;
+ apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
}
}
else if (r->proxyreq == PROXYREQ_REVERSE) {
@@ -1578,6 +1579,7 @@
*balancer = NULL;
*worker = conf->reverse;
access_status = OK;
+ apr_table_set(r->subprocess_env, "proxy-nokeepalive", "1");
}
}
}
Regards
Rüdiger