You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Dani Pardo <ji...@gmail.com> on 2008/01/24 15:05:12 UTC
[users@httpd] mod_proxy not handling redirects correctly
Hi all, I have an environment in which I reverse proxy some servers
depending on the value of a cookie, that is:
RewriteCond %{HTTP_COOKIE} ^.*destination_host=host1.*$
RewriteRule (.+) http://www.host1.com$1 [P]
RewriteCond %{HTTP_COOKIE} ^.*destination_host=host2.*$
RewriteRule (.+) http://www.host2.com$1 [P]
The idea is that I reverse proxy everything to either www.host1.com
or www.host2.com depending on the value of the cookie
"destination_host".
That's working correctly at the moment, the problem comes when the
target (host1 or host2) sends a redirect, which doesn't get reverse
proxied, and thus the browser goes directly to www.host1.com or
www.host2.com.
I could add
ProxyPassReverse / http://www.host1.com
Which will adapt the response of the redirect, but I need this rule
to depend also on the value of the cookie "destination_host".
The question is, is there any way to ProxyPassReverse depending on
the value of a cookie? Or should it be done automatically by
mod_rewrite with [P]? If so, is it a bug, or am I just doing something
wrong?
Any clue appreciated,
--
Dani
---------------------------------------------------------------------
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
Re: [users@httpd] mod_proxy not handling redirects correctly
Posted by Dani Pardo <ji...@gmail.com>.
On Jan 24, 2008 3:24 PM, Axel-Stephane SMORGRAV
<Ax...@europe.adp.com> wrote:
> You need
>
> ServerName www.mysite.com
> ProxyPassReverse / http://www.host1.com/
> ProxyPassReverse / http://www.host2.com/
>
> What ProxyPassReverse does is simply rewriting the Location headers that match the second argument:
>
> If the Location header of the HTTP 30[12] (redirect) starts with http://www.host1.com/, it will be rewritten to http://www.mysite.com/.
> If the Location header of the HTTP 30[12] (redirect) starts with http://www.host2.com/, it will be rewritten to http://www.mysite.com/ as well.
>
Thanks very much, that worked fine. I had the wrong concept about
ProxyPassReverse, now I see how it works.
--
Dani
---------------------------------------------------------------------
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
RE: [users@httpd] mod_proxy not handling redirects correctly
Posted by Axel-Stephane SMORGRAV <Ax...@europe.adp.com>.
You need
ServerName www.mysite.com
ProxyPassReverse / http://www.host1.com/
ProxyPassReverse / http://www.host2.com/
What ProxyPassReverse does is simply rewriting the Location headers that match the second argument:
If the Location header of the HTTP 30[12] (redirect) starts with http://www.host1.com/, it will be rewritten to http://www.mysite.com/.
If the Location header of the HTTP 30[12] (redirect) starts with http://www.host2.com/, it will be rewritten to http://www.mysite.com/ as well.
-ascs
-----Message d'origine-----
De : Dani Pardo [mailto:jiffier@gmail.com]
Envoyé : jeudi 24 janvier 2008 15:05
À : users@httpd.apache.org
Objet : [users@httpd] mod_proxy not handling redirects correctly
Hi all, I have an environment in which I reverse proxy some servers depending on the value of a cookie, that is:
RewriteCond %{HTTP_COOKIE} ^.*destination_host=host1.*$
RewriteRule (.+) http://www.host1.com$1 [P]
RewriteCond %{HTTP_COOKIE} ^.*destination_host=host2.*$
RewriteRule (.+) http://www.host2.com$1 [P]
The idea is that I reverse proxy everything to either www.host1.com or www.host2.com depending on the value of the cookie "destination_host".
That's working correctly at the moment, the problem comes when the target (host1 or host2) sends a redirect, which doesn't get reverse proxied, and thus the browser goes directly to www.host1.com or www.host2.com.
I could add
ProxyPassReverse / http://www.host1.com
Which will adapt the response of the redirect, but I need this rule to depend also on the value of the cookie "destination_host".
The question is, is there any way to ProxyPassReverse depending on the value of a cookie? Or should it be done automatically by mod_rewrite with [P]? If so, is it a bug, or am I just doing something wrong?
Any clue appreciated,
--
Dani
---------------------------------------------------------------------
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
Re: [users@httpd] mod_proxy not handling redirects correctly
Posted by Charles Goyard <ch...@orange-ftgroup.com>.
Hi,
Dani Pardo wrote :
> Hi all, I have an environment in which I reverse proxy some servers
> depending on the value of a cookie, that is:
>
> RewriteCond %{HTTP_COOKIE} ^.*destination_host=host1.*$
> RewriteRule (.+) http://www.host1.com$1 [P]
> RewriteCond %{HTTP_COOKIE} ^.*destination_host=host2.*$
> RewriteRule (.+) http://www.host2.com$1 [P]
>
> The idea is that I reverse proxy everything to either www.host1.com
> or www.host2.com depending on the value of the cookie
> "destination_host".
> That's working correctly at the moment, the problem comes when the
> target (host1 or host2) sends a redirect, which doesn't get reverse
> proxied, and thus the browser goes directly to www.host1.com or
> www.host2.com.
You should add both ProxyPassReverse :
ProxyPassReverse / http://www.host1.com/
ProxyPassReverse / http://www.host2.com/
it will do the trick.
Regards,
--
Charles Goyard - charles.goyard@orange-ftgroup.com - (+33) 1 45 38 01 31
Orange Business Services - online multimedia // ingénierie
---------------------------------------------------------------------
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