重写IIS 7中的响应头的规则(替换cookie路径)

Rol*_*Beh 6 iis cookies reverse-proxy url-rewriting http-headers

我必须将我的Web应用程序从apache移植到IIS 7,并在正确的配置中遇到麻烦.

在apache配置中,我配置了一些mod重写内容(为了与apache active 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 /
Run Code Online (Sandbox Code Playgroud)

我试图使用ApplicationRequestRouting配置IIS 7 .将/ foo/bar替换为localhost地址的请求中的重写规则确实有效,但是我在定义用于在响应中设置正确的cookie路径的规则时遇到了一些问题.

我已经找到了一篇关于在这里操纵回复的文章.对我来说,看起来像II7我只能操纵响应的HTTP主体.

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

响应头中的cookie路径如下所示:

Set-Cookie: JSESSIONID=1lu7hn253csbh11jax27k2i072;Path=/foo
Run Code Online (Sandbox Code Playgroud)

路径应编辑为"Path = /".

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

ami*_*t_g 9

这应该做到这一点

<?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>
Run Code Online (Sandbox Code Playgroud)

查看更详细的参考.

  • 多谢!!!它几乎不需要修改就可以工作,你刚刚节省了我的一周;)但是 REPONSE_SET_COOKIE 实际上是 RESPONSE_Set_Cookie。问候 - 罗尔夫 (2认同)