You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Zisis Lianas <Zi...@consol.de> on 2012/09/05 19:08:31 UTC
Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
There seems to be some problems when trying to proxy "/" with
ProxyPass and mod_proxy_balancer.
See also:
https://issues.apache.org/bugzilla/show_bug.cgi?id=51982
https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
I could reproduce both errors in httpd-2.4.3:
1) error 500 when configuring "ProxyPass / balancer://default"
2) double-slash problem when backend returns 301
Sample config:
########################################
ProxyPreserveHost Off
<Proxy balancer://default>
BalancerMember http://backend1.foo:5080 route=0
BalancerMember http://backend2.foo:5080 route=1
ProxySet lbmethod=bybusyness nofailover=off stickysession=JSESSIONID|jsessionid
</Proxy>
ProxyPass / balancer://default
ProxyPassReverse / balancer://default
########################################
1)
When configuring "ProxyPass / balancer://default", an error 500
occurs. When using a different ProxyPassMatch config, everything
works fine, e.g.: ProxyPassMatch ^/(.*)$ balancer://default/$1
I broke it down to mod_proxy.c::ap_proxy_trans_match().
"r->filename" resp. "found" is set to "proxy:balancer://defaultclusterjsp"
when for e.g. the URL "http://mydomain.foo/clusterjsp" is called.
"r->filename" should be "proxy:balancer://default/clusterjsp".
I wrote a patch for httpd-2.4.3 (attached) - maybe someone can
review and improve it to get it finally in trunk.
2)
When the patch from 1) is applied, you will run into another problem.
On 301 from backend, an dispensable "/" will be prepended to the URI.
E.g. when you call http://mydomain.foo:8080/clusterjsp in you browser, the
redirect location will be set wrong:
Location: http://mydomain.foo:8080//clusterjsp/
This will result in session problems... (cookie path is "/clusterjsp" and
not "//clusterjsp").
See attached logfile for more details.
A patch was proposed in https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
for httpd-2.4.x, which is working for me.
I did a quick check with:
u = apr_pstrcat(r->pool, (strcmp(ent[i].fake, "/") == 0 ? "" : ent[i].fake), &url[l2], NULL);
regards,
zisis
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Tom Evans <te...@googlemail.com>.
On Thu, Sep 6, 2012 at 4:07 PM, Zisis Lianas <Zi...@consol.de> wrote:
> Tom, thanks for your feedback.
>
> The main difference between our configurations is that you do
> ProxyPassReverse the single BalancerMember (http://app05/...),
> which is also working for me - in my configuration I ProxyPassReverse
> the "balancer://cluster". And this is the configuration which does
> not work correctly.
>
> So...
> ProxyPassReverse / http://app05/ => WORKS
> ProxyPassReverse / balancer://cluster/ => DOES NOT WORK CORRECTLY
>
> As documented the balancer://... ProxyPassReverse should work:
> http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#example
>
>
> So I think this is a bug.
>
Hmm, I'd have to check that, I thought ProxyPassReverse was straight
up string replacement, clearly not.
Cheers
Tom
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes
(httpd-2.4.3)
Posted by Micha Lenk <mi...@lenk.info>.
Hi Zisis,
Am 06.09.2012 08:07, schrieb Zisis Lianas:
> Tom, thanks for your feedback.
>
> The main difference between our configurations is that you do
> ProxyPassReverse the single BalancerMember (http://app05/...),
> which is also working for me - in my configuration I ProxyPassReverse
> the "balancer://cluster". And this is the configuration which does
> not work correctly.
>
> So...
> ProxyPassReverse / http://app05/ => WORKS
> ProxyPassReverse / balancer://cluster/ => DOES NOT WORK CORRECTLY
>
> As documented the balancer://... ProxyPassReverse should work:
> http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#example
>
> So I think this is a bug.
As Tom confirmed, this is a bug not with ProxyPass but with
ProxyPassReverse, which I also tried to report as issue #51489 (thanks
for mentioning it). I already traced it down with gdb to one particular
code path that seems to be broken. Checkout my most recently patch
attached to issue #51489 for details.
Jim, you asked what exactly DOES NOT WORK CORRECTLY mean, I will try to
describe that again in my own words. It means that ProxyPassReverse does
its job, but adds an additional slash to the redirect target URL, which
is inserted after the hostname. E.g. if the HTTP response from backend
with status code 301 contains a Location header like this:
Location: http://backend01.foo:5080/clusterjsp/
then the HTTP response from reverse proxying Apache after processing the
ProxyPassReverse configuration would look like this:
Location: http://mydomain.foo:8080//clusterjsp/
^--- this slash shouldn't be there
If you leave out the trailing slash in the ProxyPassReverse directive,
Apache is unable to process the request (HTTP 500 error mentioned by
Zisis) due to the broken configuration. If the ProxyPassReverse
configuration matches the ProxyPass configuration, you get the
additional slash.
As I wrote already above, I analyzed the code flow already and
identified where in the code the problem exists. Apparently the corner
case is hit when the destination URL in ProxyPassReverse has a
slash-only path component (i.e. '/').
The available patch attached to issue #51489 should fix the issue,
however someone more familiar with the Apache code should probably
review the patch before applying it in SVN.
Regards,
Micha
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Jim Jagielski <ji...@jaguNET.com>.
Yes, it is a bug from back when we made PPR balancer aware...
Will be fixed in trunk and proposed for 2.4.x
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
----- Original Message -----
> Try
>
> ProxyPreserveHost Off
>
> <Proxy balancer://default>
> BalancerMember http://backend01:5080/ route=0
> BalancerMember http://backend02:5080/ route=2
> BalancerMember http://backend01:5180/ route=1
> BalancerMember http://backend02:5180/ route=3
> ProxySet lbmethod=bybusyness nofailover=Off
> stickysession=JSESSIONID|jsessionid
> </Proxy>
>
> ProxyPass / balancer://default/
> ProxyPassReverse / balancer://default
>
This configuration seems to work correctly - but this a false conclusion.
If you look deeper in log output/files, you will see that there is still
a double slash inside. Fortunately the final request the browser is sending
to the apache-httpd is "/clusterjsp/", so the cookie is considered and the
session is not lost.
But on backend servers you still get the double-slashed request, e.g.:
"10.x.x.x" "17/Sep/2012:10:43:04 +0100" "GET //clusterjsp/ HTTP/1.1" 200 1590
So when you perform someting like javax.servlet.http.HttpServletRequest.getRequestURI()
on an applicationserver, you still will see the "//clusterjsp/".
Errorlog debug:
[Mon Sep 17 10:47:55.699519 2012] [proxy_balancer:trace1] [pid 5463:tid 140065930422016] mod_proxy_balancer.c(73): [client 10.x.x.x:59115] canonicalising URL //default/clusterjsp/
[Mon Sep 17 10:47:55.699558 2012] [proxy_balancer:debug] [pid 5463:tid 140065930422016] mod_proxy_balancer.c(614): [client 10.x.x.x:59115] AH01172: balancer://default: worker (http://backend02.foo:5180/) rewritten to http://backend02.foo:5180//clusterjsp/
(attached you will find the whole logfile)
Also with the two patches I mentioned in my first email, its
depended on your config whether you get the doubleslashes or
not in backend.
Maybe we can improve the URL canonicalisation, so that we are
independent of the config? The rfc is on our side ;)
http://www.ietf.org/rfc/rfc3986.txt
-> 3.3. Path
[...]
path = path-abempty ; begins with "/" or is empty
/ path-absolute ; begins with "/" but not "//"
/ path-noscheme ; begins with a non-colon segment
/ path-rootless ; begins with a segment
/ path-empty ; zero characters
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Jim Jagielski <ji...@jaguNET.com>.
Try
ProxyPreserveHost Off
<Proxy balancer://default>
BalancerMember http://backend01:5080/ route=0
BalancerMember http://backend02:5080/ route=2
BalancerMember http://backend01:5180/ route=1
BalancerMember http://backend02:5180/ route=3
ProxySet lbmethod=bybusyness nofailover=Off stickysession=JSESSIONID|jsessionid
</Proxy>
ProxyPass / balancer://default/
ProxyPassReverse / balancer://default
Agreed, that this most likely needs some cleaning up
at the code level, and will take a look start of next week.
On Sep 14, 2012, at 10:28 AM, Zisis Lianas <Zi...@consol.de> wrote:
>
> ----- Original Message -----
>> Can you forward over your exact config again?
>>
>
> e.g.:
>
> ProxyPreserveHost Off
>
> <Proxy balancer://default>
> BalancerMember http://backend01:5080 route=0
> BalancerMember http://backend02:5080 route=2
> BalancerMember http://backend01:5180 route=1
> BalancerMember http://backend02:5180 route=3
> ProxySet lbmethod=bybusyness nofailover=Off stickysession=JSESSIONID|jsessionid
> </Proxy>
>
> ProxyPass / balancer://default/
> ProxyPassReverse / balancer://default/
>
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
----- Original Message -----
> Can you forward over your exact config again?
>
e.g.:
ProxyPreserveHost Off
<Proxy balancer://default>
BalancerMember http://backend01:5080 route=0
BalancerMember http://backend02:5080 route=2
BalancerMember http://backend01:5180 route=1
BalancerMember http://backend02:5180 route=3
ProxySet lbmethod=bybusyness nofailover=Off stickysession=JSESSIONID|jsessionid
</Proxy>
ProxyPass / balancer://default/
ProxyPassReverse / balancer://default/
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Jim Jagielski <ji...@jaguNET.com>.
Can you forward over your exact config again?
Thx
On Sep 14, 2012, at 6:01 AM, Zisis Lianas <Zi...@consol.de> wrote:
>
> ----- Original Message -----
>> From: "Jim Jagielski" <ji...@jaguNET.com>
>> To: dev@httpd.apache.org
>> Sent: Thursday, September 13, 2012 8:59:27 PM
>> Subject: Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
>>
>>
>>
>> So in the case it is correctly adjusting the backend URL Location
>> (backend01.foo:5080 -> mydomain.foo:8080)
>>
>> So is the "bug" that it's
>>
>> http://mydomain.foo:8080//clusterjsp/
>>
>> and not
>>
>> http://mydomain.foo:8080/clusterjsp/
>>
>> ??
>>
>> Certainly the redirect still works, right?
>
> That's exactly the problem.
>
> The redirect works, but the subsequent request looks like "//clusterjsp/",
> which a problem because of the cookie set by the backend (Path=/clusterjsp).
> So the cookie is ignored and on each new request you get a new session.
>
>
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
----- Original Message -----
> From: "Jim Jagielski" <ji...@jaguNET.com>
> To: dev@httpd.apache.org
> Sent: Thursday, September 13, 2012 8:59:27 PM
> Subject: Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
>
>
>
> So in the case it is correctly adjusting the backend URL Location
> (backend01.foo:5080 -> mydomain.foo:8080)
>
> So is the "bug" that it's
>
> http://mydomain.foo:8080//clusterjsp/
>
> and not
>
> http://mydomain.foo:8080/clusterjsp/
>
> ??
>
> Certainly the redirect still works, right?
That's exactly the problem.
The redirect works, but the subsequent request looks like "//clusterjsp/",
which a problem because of the cookie set by the backend (Path=/clusterjsp).
So the cookie is ignored and on each new request you get a new session.
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Jim Jagielski <ji...@jaguNET.com>.
On Sep 13, 2012, at 2:06 PM, Zisis Lianas <Zi...@consol.de> wrote:
> With this configuration I get a 500 error because of
> "[proxy_balancer:trace1] ... mod_proxy_balancer.c(73): ... canonicalising
> URL //defaultclusterjsp", when trying to access "/clusterjsp":
> ProxyPass / balancer://default
> ProxyPassReverse / balancer://default
> Maybe this also expected.
>
>
> But:
> With this configuration I get the doubleslash bug, when the
> backend is returning a 301:
> ProxyPass / balancer://default/
> ProxyPassReverse / balancer://default/
>
> See also "proxypass_20120906.0.txt" attachment in one of my
> emails before with the logfile trace.
>
I see
[Thu Sep 06 13:24:00.117313 2012] [proxy_http:trace3] [pid 29121:tid 139699051894528] mod_proxy_http.c(1689): [client 10.x.x.x:56178] Status from backend: 301
[Thu Sep 06 13:24:00.117377 2012] [proxy_http:trace4] [pid 29121:tid 139699051894528] mod_proxy_http.c(1373): [client 10.x.x.x:56178] Headers received from backend:
[Thu Sep 06 13:24:00.117416 2012] [proxy_http:trace4] [pid 29121:tid 139699051894528] mod_proxy_http.c(1375): [client 10.x.x.x:56178] Location: http://backend01.foo:5080/clusterjsp/
...
[Thu Sep 06 13:24:00.117891 2012] [http:trace3] [pid 29121:tid 139699051894528] http_filters.c(963): [client 10.x.x.x:56178] Response sent with status 301, headers:
[Thu Sep 06 13:24:00.117977 2012] [http:trace4] [pid 29121:tid 139699051894528] http_filters.c(806): [client 10.x.x.x:56178] Location: http://mydomain.foo:8080//clusterjsp/
So in the case it is correctly adjusting the backend URL Location (backend01.foo:5080 -> mydomain.foo:8080)
So is the "bug" that it's
http://mydomain.foo:8080//clusterjsp/
and not
http://mydomain.foo:8080/clusterjsp/
??
Certainly the redirect still works, right?
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
With this configuration I get a 500 error because of
"[proxy_balancer:trace1] ... mod_proxy_balancer.c(73): ... canonicalising
URL //defaultclusterjsp", when trying to access "/clusterjsp":
ProxyPass / balancer://default
ProxyPassReverse / balancer://default
Maybe this also expected.
But:
With this configuration I get the doubleslash bug, when the
backend is returning a 301:
ProxyPass / balancer://default/
ProxyPassReverse / balancer://default/
See also "proxypass_20120906.0.txt" attachment in one of my
emails before with the logfile trace.
----- Original Message -----
From: "Jim Jagielski" <ji...@jaguNET.com>
To: dev@httpd.apache.org
Sent: Thursday, September 13, 2012 6:54:36 PM
Subject: Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
On Sep 6, 2012, at 11:07 AM, Zisis Lianas <Zi...@consol.de> wrote:
> Tom, thanks for your feedback.
>
> The main difference between our configurations is that you do
> ProxyPassReverse the single BalancerMember (http://app05/...),
> which is also working for me - in my configuration I ProxyPassReverse
> the "balancer://cluster". And this is the configuration which does
> not work correctly.
>
> So...
> ProxyPassReverse / http://app05/ => WORKS
> ProxyPassReverse / balancer://cluster/ => DOES NOT WORK CORRECTLY
>
> As documented the balancer://... ProxyPassReverse should work:
> http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#example
>
>
How is it not working for you?
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Jim Jagielski <ji...@jaguNET.com>.
On Sep 6, 2012, at 11:07 AM, Zisis Lianas <Zi...@consol.de> wrote:
> Tom, thanks for your feedback.
>
> The main difference between our configurations is that you do
> ProxyPassReverse the single BalancerMember (http://app05/...),
> which is also working for me - in my configuration I ProxyPassReverse
> the "balancer://cluster". And this is the configuration which does
> not work correctly.
>
> So...
> ProxyPassReverse / http://app05/ => WORKS
> ProxyPassReverse / balancer://cluster/ => DOES NOT WORK CORRECTLY
>
> As documented the balancer://... ProxyPassReverse should work:
> http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#example
>
>
How is it not working for you?
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
Tom, thanks for your feedback.
The main difference between our configurations is that you do
ProxyPassReverse the single BalancerMember (http://app05/...),
which is also working for me - in my configuration I ProxyPassReverse
the "balancer://cluster". And this is the configuration which does
not work correctly.
So...
ProxyPassReverse / http://app05/ => WORKS
ProxyPassReverse / balancer://cluster/ => DOES NOT WORK CORRECTLY
As documented the balancer://... ProxyPassReverse should work:
http://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html#example
So I think this is a bug.
----- Original Message -----
From: "Tom Evans" <te...@googlemail.com>
To: dev@httpd.apache.org
Sent: Thursday, September 6, 2012 4:40:18 PM
Subject: Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
On Thu, Sep 6, 2012 at 12:42 PM, Zisis Lianas <Zi...@consol.de> wrote:
> Also with the trailing slash the config does not work correctly,
> see attached logfile. Please keep in mind that this only happens
> if the backend returns a 301.
>
> Status from backend: 301
> Location: http://backend01.foo:5080/clusterjsp/
> [...]
> Response sent with status 301, headers:
> Location: http://mydomain.foo:8080//clusterjsp/
> [...]
> Request received from client: GET //clusterjsp/ HTTP/1.0
>
>
Only if your configuration is incorrect. The behaviour you are talking
about is solely concerned with how you have configured
ProxyPassReverse, which you have not shown. If you have incorrectly
matched '/'s on ProxyPassReverse, you will also have issues.
With ProxyPass and ProxyPassReverse, if the first argument ends in a
slash, so should the second. Eg, straight from my production
httpd.conf:
<Proxy balancer://cluster>
BalancerMember http://app05 retry=0
BalancerMember http://app07 retry=0 status=+H
</Proxy>
ProxyPass / balancer://cluster/
ProxyPassReverse / http://app05/
ProxyPassReverse / http://app07/
This configuration works correctly in all cases.
Cheers
Tom
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Tom Evans <te...@googlemail.com>.
On Thu, Sep 6, 2012 at 12:42 PM, Zisis Lianas <Zi...@consol.de> wrote:
> Also with the trailing slash the config does not work correctly,
> see attached logfile. Please keep in mind that this only happens
> if the backend returns a 301.
>
> Status from backend: 301
> Location: http://backend01.foo:5080/clusterjsp/
> [...]
> Response sent with status 301, headers:
> Location: http://mydomain.foo:8080//clusterjsp/
> [...]
> Request received from client: GET //clusterjsp/ HTTP/1.0
>
>
Only if your configuration is incorrect. The behaviour you are talking
about is solely concerned with how you have configured
ProxyPassReverse, which you have not shown. If you have incorrectly
matched '/'s on ProxyPassReverse, you will also have issues.
With ProxyPass and ProxyPassReverse, if the first argument ends in a
slash, so should the second. Eg, straight from my production
httpd.conf:
<Proxy balancer://cluster>
BalancerMember http://app05 retry=0
BalancerMember http://app07 retry=0 status=+H
</Proxy>
ProxyPass / balancer://cluster/
ProxyPassReverse / http://app05/
ProxyPassReverse / http://app07/
This configuration works correctly in all cases.
Cheers
Tom
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Zisis Lianas <Zi...@consol.de>.
Also with the trailing slash the config does not work correctly,
see attached logfile. Please keep in mind that this only happens
if the backend returns a 301.
Status from backend: 301
Location: http://backend01.foo:5080/clusterjsp/
[...]
Response sent with status 301, headers:
Location: http://mydomain.foo:8080//clusterjsp/
[...]
Request received from client: GET //clusterjsp/ HTTP/1.0
----- Original Message -----
From: "Tom Evans" <te...@googlemail.com>
To: dev@httpd.apache.org
Sent: Thursday, September 6, 2012 12:49:03 PM
Subject: Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
On Wed, Sep 5, 2012 at 6:08 PM, Zisis Lianas <Zi...@consol.de> wrote:
> There seems to be some problems when trying to proxy "/" with
> ProxyPass and mod_proxy_balancer.
>
> See also:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51982
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
>
> I could reproduce both errors in httpd-2.4.3:
> 1) error 500 when configuring "ProxyPass / balancer://default"
> 2) double-slash problem when backend returns 301
>
>
>
> Sample config:
> ########################################
> ProxyPreserveHost Off
> <Proxy balancer://default>
> BalancerMember http://backend1.foo:5080 route=0
> BalancerMember http://backend2.foo:5080 route=1
> ProxySet lbmethod=bybusyness nofailover=off stickysession=JSESSIONID|jsessionid
> </Proxy>
>
> ProxyPass / balancer://default
> ProxyPassReverse / balancer://default
> ########################################
>
>
> 1)
> When configuring "ProxyPass / balancer://default", an error 500
> occurs. When using a different ProxyPassMatch config, everything
> works fine, e.g.: ProxyPassMatch ^/(.*)$ balancer://default/$1
>
> I broke it down to mod_proxy.c::ap_proxy_trans_match().
> "r->filename" resp. "found" is set to "proxy:balancer://defaultclusterjsp"
> when for e.g. the URL "http://mydomain.foo/clusterjsp" is called.
> "r->filename" should be "proxy:balancer://default/clusterjsp".
>
> I wrote a patch for httpd-2.4.3 (attached) - maybe someone can
> review and improve it to get it finally in trunk.
This is because the configuration is incorrect. Your ProxyPassMatch
corresponds to this ProxyPass line
ProxyPass / balancer://default/
Not this
ProxyPass / balancer://default
The trailing slash is relevant, as you have found out.
>
>
> 2)
> When the patch from 1) is applied, you will run into another problem.
> On 301 from backend, an dispensable "/" will be prepended to the URI.
> E.g. when you call http://mydomain.foo:8080/clusterjsp in you browser, the
> redirect location will be set wrong:
> Location: http://mydomain.foo:8080//clusterjsp/
>
> This will result in session problems... (cookie path is "/clusterjsp" and
> not "//clusterjsp").
>
> See attached logfile for more details.
>
> A patch was proposed in https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
> for httpd-2.4.x, which is working for me.
>
> I did a quick check with:
> u = apr_pstrcat(r->pool, (strcmp(ent[i].fake, "/") == 0 ? "" : ent[i].fake), &url[l2], NULL);
This "problem" comes from incorrectly fixing problem 1.
Cheers
Tom
Re: Bug with "ProxyPass /" and mod_proxy_balancer + double-slashes (httpd-2.4.3)
Posted by Tom Evans <te...@googlemail.com>.
On Wed, Sep 5, 2012 at 6:08 PM, Zisis Lianas <Zi...@consol.de> wrote:
> There seems to be some problems when trying to proxy "/" with
> ProxyPass and mod_proxy_balancer.
>
> See also:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51982
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
>
> I could reproduce both errors in httpd-2.4.3:
> 1) error 500 when configuring "ProxyPass / balancer://default"
> 2) double-slash problem when backend returns 301
>
>
>
> Sample config:
> ########################################
> ProxyPreserveHost Off
> <Proxy balancer://default>
> BalancerMember http://backend1.foo:5080 route=0
> BalancerMember http://backend2.foo:5080 route=1
> ProxySet lbmethod=bybusyness nofailover=off stickysession=JSESSIONID|jsessionid
> </Proxy>
>
> ProxyPass / balancer://default
> ProxyPassReverse / balancer://default
> ########################################
>
>
> 1)
> When configuring "ProxyPass / balancer://default", an error 500
> occurs. When using a different ProxyPassMatch config, everything
> works fine, e.g.: ProxyPassMatch ^/(.*)$ balancer://default/$1
>
> I broke it down to mod_proxy.c::ap_proxy_trans_match().
> "r->filename" resp. "found" is set to "proxy:balancer://defaultclusterjsp"
> when for e.g. the URL "http://mydomain.foo/clusterjsp" is called.
> "r->filename" should be "proxy:balancer://default/clusterjsp".
>
> I wrote a patch for httpd-2.4.3 (attached) - maybe someone can
> review and improve it to get it finally in trunk.
This is because the configuration is incorrect. Your ProxyPassMatch
corresponds to this ProxyPass line
ProxyPass / balancer://default/
Not this
ProxyPass / balancer://default
The trailing slash is relevant, as you have found out.
>
>
> 2)
> When the patch from 1) is applied, you will run into another problem.
> On 301 from backend, an dispensable "/" will be prepended to the URI.
> E.g. when you call http://mydomain.foo:8080/clusterjsp in you browser, the
> redirect location will be set wrong:
> Location: http://mydomain.foo:8080//clusterjsp/
>
> This will result in session problems... (cookie path is "/clusterjsp" and
> not "//clusterjsp").
>
> See attached logfile for more details.
>
> A patch was proposed in https://issues.apache.org/bugzilla/show_bug.cgi?id=51489
> for httpd-2.4.x, which is working for me.
>
> I did a quick check with:
> u = apr_pstrcat(r->pool, (strcmp(ent[i].fake, "/") == 0 ? "" : ent[i].fake), &url[l2], NULL);
This "problem" comes from incorrectly fixing problem 1.
Cheers
Tom