This report appears similar to some others, like 39203 and particularly 51489. But I believe the following configuration demonstrates a specific problem simply and is in fact a bug - feel free to prove me wrong: <Proxy balancer://cluster > BalancerMember http://localhost:8080 </Proxy> ProxyPass / balancer://cluster/ # option 1 ProxyPassReverse / http://localhost:8080/ # option 2 ProxyPassReverse / balancer://cluster/ Option 1 and 2 should both correctly rewrite Location: headers from the backend. Option 1 does, but option 2 adds an extra / - so if the request was http://www.example.com/foo and the backend returns a Location: http://localhost:8080/foo/ then the rewritten result will be http://www.example.com//foo/ (with two slashes). Aside from looking/being incorrect, any cookies with path /foo (as is common with backend applications) won't match this path and thus the browser won't send them after the redirect. Some things to note: 1. The behavior is no different with: ProxyPassReverse / balancer://cluster (i.e. without the trailing /) 2. This works fine if you do the following instead: ProxyPass /foo balancer://cluster/foo ProxyPassReverse /foo balancer://cluster ... however, the goal here is to proxy / (perhaps with exceptions) so there is no way to eliminate the trailing slashes. 3. You can try other combinations of adding/removing trailing slashes to your heart's content - I have not found one that both proxies to the correct backend location (without adding/removing a slash) and rewrites Location correctly. The only workaround is to ProxyPassReverse each of the individual BalancerMembers, which is what the balancer:// construct is intended to avoid.
I ran into this problem too and didn't find a workaround yet. My config # Works perfect ProxyPass / http://localhost:9381/ ProxyPassReverse / http://localhost:9381/ # Doesn't work when receiving Redirects / Location from the backend. An extra leading '/' is added. # # ProxyPass / balancer://balancer/ # ProxyPassReverse / balancer://balancer/ <Proxy balancer://balancer/> BalancerMember http://localhost:9381/ retry=1 BalancerMember http://localhost:9382/ retry=1 status=D </Proxy> Any workaround is appreciated.
This bug also exists in apache 2.2.12 and 2.2.22
(In reply to comment #2) > This bug also exists in apache 2.2.12 and 2.2.22 Patch available in https://issues.apache.org/bugzilla/show_bug.cgi?id=51489 solved the issue for me.
Does somebody have a patch for 2.2.22 for this? The above patch seems to be for an older version and the logic seemed to have changed (I only checked .21 and .22).
The workaround to this problem is to put multiple ProxyPassReverse directives, one for each balancer member ProxyPass / balancer://balancer/ ProxyPassReverse / http://localhost:9381/ ProxyPassReverse / http://localhost:9382/ Does anybody know if this is fixed in a later version of Httpd? If so which versions?
Created attachment 30179 [details] httpd-2.2 backport of proxy doubleslash fixes r1386576, r1386578 Folks, please test the attached backport before I submit it to STATUS.
William, your changes for the httpd-2.2 proxy double slash tested successfully. Thanks.
Added to 2.2 STATUS for review.
This is now committed for inclusion in a future 2.2.25
I don't think the backport was applied successfully in 2.2.26. That is, I believe this issue remains unresolved in 2.2.26. (I ran into it on 2.2.22, and found identical behavior in 2.2.26.) I ended up migrating to 2.4(.9) where it is in fact resolved. I don't have time to recreate my 2.2.26 conf details here, but I can attest we saw this exact problem: extra slash introduced in Location header of redirect response from proxied apps, when proxying to a balancer (vs directly to a particular member -- which didn't meet our needs). Sorry for not having more rigorous details to reprod, but for anyone reading this experiencing frustration, may I heartily recommend biting the bullet and upgrading to 2.4. In the end our conf is cleaner and more concise, and mod_proxy_balancer + mod_rewrite are working in perfect harmony to route requests to one of multiple load-balanced apps behind a given apache. I'm reopening this to draw attention to it, but sorry in advance for not having time to discuss it much further.
(In reply to cweekly from comment #10) > I don't think the backport was applied successfully in 2.2.26. That is, I > believe this issue remains unresolved in 2.2.26. (I ran into it on 2.2.22, > and found identical behavior in 2.2.26.) I ended up migrating to 2.4(.9) > where it is in fact resolved. > > I don't have time to recreate my 2.2.26 conf details here, but I can attest > we saw this exact problem: extra slash introduced in Location header of > redirect response from proxied apps, when proxying to a balancer (vs > directly to a particular member -- which didn't meet our needs). > > Sorry for not having more rigorous details to reprod, but for anyone reading > this experiencing frustration, may I heartily recommend biting the bullet > and upgrading to 2.4. In the end our conf is cleaner and more concise, and > mod_proxy_balancer + mod_rewrite are working in perfect harmony to route > requests to one of multiple load-balanced apps behind a given apache. > > I'm reopening this to draw attention to it, but sorry in advance for not > having time to discuss it much further. I am actually getting the same behavior in apache 2.4. The forward slash is being appended to the balancermember below. Is there a workaround / patch? VERSION Server version: Apache/2.4.6 (CentOS) Server built: Mar 24 2022 14:57:57 CONFIGURATION <Proxy "balancer://cluster"> BalancerMember http://testsite/something </Proxy> <Location /test/v1> Require all granted ProxyPass balancer://cluster ProxyPassReverse balancer://cluster </Location>