You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by LECONTE Laurent ROSI/SICOR <la...@francetelecom.com> on 2005/11/09 16:42:59 UTC

[users@httpd] Mod_rewrite and mod_proxy

Hello all,

I've configured an Apache 2.0 instance to work as a reverse proxy,
listening on external.address.com and redirecting to
internal.address.com.

The relevant lines of the httpd.conf file are :

Listen external.address.com:80

<VirtualHost external.address.com:80>
ProxyPass / http://internal.address.com/
ProxyPassReverse / http://internal.address.com/
</VirtualHost>

This works fine, and all our URLs (which look like
http://external.address.com/newsite/whatever) are correctly rerouted to
http://internal.address.com/newsite/whatever

However, we'd like to maintain backwards-compatibility with the old
site. This means that the old URLs such as
http://external.address.com/images/xyz or
http://external.address.com/html/abc should be rewritten as
http://external.address.com/newsite/images/xyz or
http://external.address.com/newsite/html/abc BEFORE going through
mod_proxy. Accordingly, I've tried modifying the VirtualHost section so
:

<VirtualHost external.address.com:80>
RewriteEngine on
RewriteLog /path/to/logs/rewrite_log
RewriteLogLevel 100
RewriteRule ^/images/(.*) /newsite/images/$1 [L]
RewriteRule ^/html/(.*) /newsite/html/$1 [L]
...
ProxyPass / http://internal.address.com/
ProxyPassReverse / http://internal.address.com/
</VirtualHost>

This, however, doesn't work. The log file is created, but stays
desesperately empty, and all the requests to
http://external.address.com/html/abc are directly rerouted to
http://internal.address.com/html/abc

I've tried replacing [L] by [P] or [QSA] in the rules, and placing the
Rewrite directives outside of the VirtualHost section, but that doesn't
change anything. I've read in the archive that using [P] and removing
the ProxyPass directive should work, but that would break the
redirection for the new URLs.

The httpd -l command shows mod_rewrite.c, so the module is indeed here.

Any thoughts on what I'm doing wrong ?

Thanks in advance.

Regards,
Laurent Leconte


***********************************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de
ses destinataires.
Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration. Le Groupe France Telecom decline toute responsabilite au titre de
ce message s'il a ete altere, deforme ou falsifie.
Si vous n'etes pas destinataire de ce message, merci de le detruire immediatement et d'avertir l'expediteur.
***********************************
This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised
use or dissemination is prohibited.
Messages are susceptible to alteration. France Telecom Group shall not be liable for the message if altered, changed or
falsified.
If you are not receiver of this message, please cancel it immediately and inform the sender.
***********************************

---------------------------------------------------------------------
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_rewrite and mod_proxy

Posted by Simon Irwin <si...@gmail.com>.
Laurent -

did you test whether mod_rewrite will work on any requests if you
remove the ProxyPass directives?  it would be good to find out if the
rewrite engine is basically working for you.

if you can prove the rewrite engine works, perhaps you could avoid
using ProxyPass/ProxyPassReverse altogether and instead implement of
all your redirects using only mod_rewrite's RewriteRule directives.

cheers
Simon

On 11/9/05, LECONTE Laurent ROSI/SICOR
<la...@francetelecom.com> wrote:
>
> Hello all,
>
> I've configured an Apache 2.0 instance to work as a reverse proxy,
> listening on external.address.com and redirecting to
> internal.address.com.
>
> The relevant lines of the httpd.conf file are :
>
> Listen external.address.com:80
>
> <VirtualHost external.address.com:80>
> ProxyPass / http://internal.address.com/
> ProxyPassReverse / http://internal.address.com/
> </VirtualHost>
>
> This works fine, and all our URLs (which look like
> http://external.address.com/newsite/whatever) are correctly rerouted to
> http://internal.address.com/newsite/whatever
>
> However, we'd like to maintain backwards-compatibility with the old
> site. This means that the old URLs such as
> http://external.address.com/images/xyz or
> http://external.address.com/html/abc should be rewritten as
> http://external.address.com/newsite/images/xyz or
> http://external.address.com/newsite/html/abc BEFORE going through
> mod_proxy. Accordingly, I've tried modifying the VirtualHost section so
> :
>
> <VirtualHost external.address.com:80>
> RewriteEngine on
> RewriteLog /path/to/logs/rewrite_log
> RewriteLogLevel 100
> RewriteRule ^/images/(.*) /newsite/images/$1 [L]
> RewriteRule ^/html/(.*) /newsite/html/$1 [L]
> ...
> ProxyPass / http://internal.address.com/
> ProxyPassReverse / http://internal.address.com/
> </VirtualHost>
>
> This, however, doesn't work. The log file is created, but stays
> desesperately empty, and all the requests to
> http://external.address.com/html/abc are directly rerouted to
> http://internal.address.com/html/abc
>
> I've tried replacing [L] by [P] or [QSA] in the rules, and placing the
> Rewrite directives outside of the VirtualHost section, but that doesn't
> change anything. I've read in the archive that using [P] and removing
> the ProxyPass directive should work, but that would break the
> redirection for the new URLs.
>
> The httpd -l command shows mod_rewrite.c, so the module is indeed here.
>
> Any thoughts on what I'm doing wrong ?
>
> Thanks in advance.
>
> Regards,
> Laurent Leconte
>
>
> ***********************************
> Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de
> ses destinataires.
> Toute utilisation ou diffusion non autorisee est interdite.
> Tout message electronique est susceptible d'alteration. Le Groupe France Telecom decline toute responsabilite au titre de
> ce message s'il a ete altere, deforme ou falsifie.
> Si vous n'etes pas destinataire de ce message, merci de le detruire immediatement et d'avertir l'expediteur.
> ***********************************
> This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised
> use or dissemination is prohibited.
> Messages are susceptible to alteration. France Telecom Group shall not be liable for the message if altered, changed or
> falsified.
> If you are not receiver of this message, please cancel it immediately and inform the sender.
> ***********************************
>
> ---------------------------------------------------------------------
> 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
>
>

---------------------------------------------------------------------
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