httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DM <donalmurt...@yahoo.co.uk>
Subject [users@httpd] mod_rewrite & mod_proxy
Date Tue, 14 Nov 2006 16:27:12 GMT
Hi,

I was presented with the seemingly straightforward task of converting URLs such as:

http://cellularmanagerpp.aliant.net/myProg?param1=val1&url=http://cellularmanagerpp.aliant.net&param3=val3

to:

http://erie:9090/myProg?param1=val1&url=http://erie:9090&param3=val3


Attempt 1
---------------
Use a reverse proxy to forward the request to erie:9090 and use mod_rewrite to change the
value of the "url" query parameter.

####################### httpd.conf #######################
RewriteEngine on

# This changes the 'url' query param
RewriteCond %{QUERY_STRING}  ^(.*)url=http%3A%2F%2Fcellularmanagerpp%2Ealiant%2Enet(.*)$
RewriteRule ^(.*)$           $1?%1url=http\%3A\%2F\%2Ferie\%3A9090%2 [P]

ProxyRequests Off

<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>

# This should redirect the request to erie:9090
ProxyPass / http://erie:9090
ProxyPassReverse / http://erie:9090/
#######################################################


The re-writing appeared to work fine, but it seemed the rewritten URLs weren't being sent
to the proxy.


Attempt 2
---------------

Use mod_rewrite to change the entire URL (i.e. not just the parameter value), and a reverse
proxy to change the hostname in the response

####################### httpd.conf #######################

RewriteEngine on

# This changes the 'url' query param
RewriteCond %{QUERY_STRING}  ^(.*)url=http%3A%2F%2Fcellularmanagerpp%2Ealiant%2Enet(.*)$
RewriteRule ^(.*)$           $1?%1url=http\%3A\%2F\%2Ferie\%3A9090%2 [NE]

# This changes the hostname
RewriteRule ^/(.*)$          http://erie:9090/$1 [P,QSA,L]

ProxyRequests Off

<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>

# This makes the response look like it came from Apache, rather than erie:9090
ProxyPassReverse / http://erie:9090/
#######################################################

This appears to work. However, because I'm using mod_rewrite, only the request line is changed.
For example, the value of the "referrer" header still references "cellularmanagerpp.aliant.net".


Anyway, my questions are these:

- Why didn't the proxying work with the rewritten URLs in Attempt 1?
- Is there a way to achieve my goal which also rewrites the headers?
- In httpd.conf it possible to set a variable whose value is "erie", then reference this variable,
so that I don't have to repeat "erie" in multiple places?


Many thanks in advance,
DM

Send instant messages to your online friends http://uk.messenger.yahoo.com 

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


Mime
View raw message