Appending request headers to a request forwarded by mod_rewrite

Set an environment variable using env flag in RewriteRule and use it in RequestHeader append.

  RewriteEngine on
  RewriteRule ^/(.*)$ http://appserver/$1 [P,L,QSA,env=ORG_REMOTE_ADDR:%{REMOTE_ADDR}]
  ProxyPassReverse / http://appserver/
  RequestHeader append X_ORG_REMOTE_ADDR %{ORG_REMOTE_ADDR}e env=ORG_REMOTE_ADDR
  RequestHeader append X-Forwarded-Proto https

mod_rewrite - Apache HTTP Server
たまねぎプログラマハマリ日記:Apache内のCGI環境変数をTomcatに渡す。 - livedoor Blog(ブログ)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.