Re: Rewrite Rule using HTTP Header information

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

 



On 11/07/07, Paul Kuykendall <pkuyken@xxxxxxxxx> wrote:
I am trying to get a rewrite rule working that will take the value
from an HTTP header and use the value to create a new target
destination for the HTTP request.  An example of what I'm trying to do
follows:

Original HTTP request being sent to http://myhost.domain/ containing the header
MyRoutingID: SOME_VALUE

This needs to be rewritten and sent to http://myhost.domain/SOME_VALUE

This will then be forwarded using a reverse proxy to
http://apphost.domain/SomeLocation/SomeApplication

I don't understand this part. How can you forward one url to another?

I know that this may seem like a really convoluted way of doing
things, but our clients don't actually know where they are sending
requests to, other than the server name.  The receiving server has to
pass the request along based on the routing ID; however, the routing
ID isn't actually part of the final destination URL.  The routing ID
-> destination URL mapping will be generated and included as an
external config file loaded into the Apache configuration at load.

So far what I have is the following:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

ProxyRequests Off
ProxyPass /SOME_VALUE http://apphost.domain/SomeLocation/SomeApplication

<Location /SOME_VALUE>
    ProxyPassReverse /SomeLocation/SomeApplication
</Location>


LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP:MyRoutingID} (.*)
RewriteRule .* - [E=ROUTING_ID:$1]

RewriteRule ^/(.*) http://myhost.domain/%{ROUTING_ID} [P,L]

The proxy config is working fine.  The RewriteRule however, does not.
Thanks for any help on getting the RewriteRule working.

These two parts of your config do different and conflicting things.
Are you expecting the rewrite to the address containing the ROUTING_ID
to be then forwarded by your ProxyPass? If so, why the double
indirection? In any case there's a few errors in the rule, this might
work better.

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP:MyRoutingID} (.*)
# Not that captures from conditions are reading using %n rather than $n
RewriteRule ^/(.*) http://myhost.domain/%1 [P,L]


--
noodl

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