Apache反向代理规则从URI信息创buildHTTP标头?

我正在testingSiteMinder后面生产中托pipe的Web应用程序,该应用程序对用户进行身份validation,并向每个标识该用户的请求添加一个HTTP标头。

如果标题不存在,应用程序不起作用,我试图用Watir和Webdriver来testing它。 这种组合在本地驱动一个真正的浏览器(例如Firefox),所以我不能通过WebDriver轻松地插入HTTP头。 我们的本地testing环境没有SiteMinder,所以我需要一种方法来插入标题。

我已经将Apache 2设置为反向代理,并且想要翻译如下请求:

GET /[email protected]/application/index.html 

成:

 GET /application/index.html SM_USER: [email protected] 

我们的服务器都是Solaris 10,而且我正在使用与OS一起安装的Apache / 2.0.63(我们没有使用它)。

我得到的最接近的是使用SetEnvIfmod_rewrite

 SetEnvIf Request_URI "SM_USER=([^/]+)" HTTP_SM_USER=$1 RewriteEngine on RewriteRule ^/.+(/application/.+)$ http://apphost:9090$1 [P] 

但标题没有被设置。 在执行SetEnvIf指令之前 ,似乎Request_URI的值正在重写,所以SM_USER不再位于URI中。

如果我对此正确,是否有可能改变执行的顺序,所以SetEnvIf获取原始URI? 或者我需要一个不同的方法?

我的同事提出了一个解决scheme。 我错误地认为使用SetEnvIf本身就足够了。 这现在正在为我们工作:

 RewriteEngine on # Anything ending with /application/.+ goes to http://apphost:9090 RewriteRule ^/.+(/application/.+)$ http://apphost:9090$1 [P] # Match SM_USER= in the URI and set an env var with its value. SetEnvIf Request_URI "SM_USER=([^/]+)" SM_USER=$1 # If the env var is set, put the value into a request header. RequestHeader set SM_USER "%{SM_USER}e" env=SM_USER 

此URI代理为http://apphost:9090/application/index.html ,并将HTTP标头SM_USER设置为[email protected]

 /[email protected]/application/index.html