Forum Moderators: phranque

Message Too Old, No Replies

How do I populate environment variable with rewrite buffer contents

         

dmwaff

11:29 pm on Feb 18, 2010 (gmt 0)

10+ Year Member



I am attempt to buffer a query parameter and set the value in an environment variable to overwrite the X-Forwarded-For header, but with out success.

Something like below. For testing, we would like to process passed ips, but internally the application is always getting the NAT ip. I need to capture the query value and pass to the application as the X-Fowarded-For header.

If hardcode the set I do notice that the app gets a comma list of forwarded ips, which I do understand why that is happening. <hardcode ip>,<fw ip> Hope to clobber and send one down. The important thing I need to capture via query string. My %{FOO}e is reporting (null).


[sitename...]

RewriteEngine on
RewriteRule ^/\?ip=(.*)$ - [E=FOO:$1]
RewriteRule ^/? balancer://clusterName/appcontext/file.jsp [P,QSA,L]

<Proxy balancer://clusterName>
RequestHeader unset X-Forwarded-For
RequestHeader set X-Forwarded-For %{FOO}e
Header echo X-Forwarded-For
BalancerMember [<app>:<port>...] options=value
</Proxy>

Still researching the proxy interpolate env directive(s).

Any ideas?

David

jdMorgan

1:11 am on Feb 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule cannot 'see' query strings. Use a RewriteCond to create a back-reference:

RewriteCond %{QUERY_STRING} ^ip=(.*)$
RewriteRule ^/$ - [E=FOO:%1]

Jim