2011-03-18 121 views
5

我必须将我的web应用程序从apache移植到IIS 7,并因适当的配置而陷入困境。在IIS 7中重写响应标头的规则(替换cookie路径)

在Apache配置,我配置一些国防部重写的东西(为了与Apache活性MQ通信)所示:

#Reverse-Proxy to ActiveMQ AJAX-Interface 
ProxyPass  /foo/bar/amq http://localhost:8161/foo/amq/ 
ProxyPassReverse /foo/bar/amq http://localhost:8161/foo/amq/ 
ProxyPassReverseCookiePath /foo/

我已经尝试通过使用ApplicationRequestRouting配置IIS 7。 将/ foo/bar替换为localhost地址的请求中的重写规则已经可以工作,但是我在定义响应中设置正确的cookie路径的规则时遇到了一些问题。

我已经找到一篇关于操纵回复的文章here。 对我来说,它看起来像II7我只能操纵响应的HTTP正文。

如何操作响应头以编辑cookie路径的方式?

在响应报头中的Cookie路径看起来像这样:

Set-Cookie: JSESSIONID=1lu7hn253csbh11jax27k2i072;Path=/foo 

的路径应该被编辑为“路径= /”。

感谢您的时间和你的帮助 罗尔夫

回答

8

这应该这样做

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <outboundRules> 
       <remove name="Update Cookie Path" /> 
       <rule name="Update Cookie Path"> 
        <match serverVariable="RESPONSE_Set_Cookie" pattern="^(.*; path=/)foo$" /> 
        <conditions /> 
        <action type="Rewrite" value="{R:1}" /> 
       </rule> 
      </outboundRules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

检查更详细的reference

+0

Thx很多!!!它几乎没有修改,你只是保存了我的一周;)但是REPONSE_SET_COOKIE实际上是RESPONSE_Set_Cookie。问候 - Rolf – 2011-03-20 11:12:31