httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Hughes '89" <bria...@Alum.Dartmouth.ORG>
Subject Re: [users@httpd] Rewriting headers
Date Fri, 20 May 2005 16:10:27 GMT
On May 20, 2005, at 06:04 AM, Alexander Mueller wrote:
> I am looking for a way to rewrite HTTP headers of requests passing 
> through in proxy mode (mod_proxy). This works in connection with 
> mod_headers, however it only allows basic manipulation (adding, 
> removing, changing). I would need a way to use values of existing 
> headers and incorporate them into newly added ones.
> Is there maybe already some solution/module which provides such 
> functionality or would it require a modification of mod_headers? 
> Thanks for any insight.

Yes. This is what the mod_rewrite module is for. What you need to do is 
not use mod_proxy directly (i.e. ProxyPass), but do your reverse proxy 
handling through mod_rewrite (the [P] flag for RewriteRule). That way, 
you can use mod_rewrite to grab an HTTP header value and place it into 
an environment variable. That would allow you to access that value via 
mod_headers, before you go back to mod_rewrite to do the reverse proxy 

Here's an example...

     RewriteEngine on

     # Get the custom header value and store in a temporary environment 
     RewriteCond %{HTTP:X-Custom-Header-Name} (.*)
     RewriteRule .* - [E=FOO_HEADER:%1]

     # We need the FOO_HEADER on the proxy side of things, so we grab 
the value from the temp
     # variable and add it as a new HTTP header for the upcoming proxy 
     RequestHeader add X-My-FOO %{FOO_HEADER}e

     # Send our request to the proxy location
     RewriteRule ^/(.*)$$1 [P,L]


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message