[users@httpd] mod_rewrite & mod_proxy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux