IIS 反向代理不使用 ASP.NET 中的 Response.Redirect()

Hoc*_*eyJ 3 iis rewrite asp.net reverse-proxy iis-7.5

我正在尝试使用此处此处此处的教程设置反向代理。

该站点设置在localhost:8080,反向代理使用localhost:8080/myProxy.

处理标准链接时,一切都很好。我可以查看代理 url 并按预期查看所有内容。从链接localhost:8080/myProxy/default.aspx进入localhost:8080/myProxy/about.aspx预期。

我遇到的问题是,在使用 .NET 的地方Response.Redirect(),url 更改为网站的实际位置,而不是代理。

即链接来自localhost:8080/myproxy/default.aspx-> localhost:8080/about.aspx

请问我该如何解决?

这是我的配置:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <urlCompression doStaticCompression="false" doDynamicCompression="false" 
                    dynamicCompressionBeforeCache="false" />
    <rewrite>
        <rules>
            <rule name="Reverse Proxy to my site" stopProcessing="true">
                <match url="^myProxy/(.*)" />
                <action type="Rewrite" url="http://localhost:8080/{R:1}" />
            </rule>
        </rules>

        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script"
                       pattern="^http(s)?://localhost:8080/(.*)" />
                <action type="Rewrite" value="/myProxy/{R:2}" />
            </rule>
            <rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" 
                       pattern="^/(.*)" negate="false" />
                <action type="Rewrite" value="/myProxy/{R:1}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>

    </rewrite>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

Hoc*_*eyJ 5

很抱歉回答我自己的问题,但我认为这值得为其他人提供信息:

使用时Response.Redirect,出站规则开始发挥作用。使用 Fiddler 查看请求有助于弄清楚链接发生了什么。

Response.Redirect()试图发送到/About.aspx(响应头中的传输)。

这没有被正则表达式所接受。

我需要的唯一出站规则是设置Response_location如下:

<rule name="Response Status Update" preCondition="ResponseStatus" stopProcessing="true">
  <match serverVariable="RESPONSE_Location" pattern="^/(.*)" />
  <action type="Rewrite" value="http://myServer:8080/myProxy/{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)

入站规则保持不变。