Problem with outbound rules when setting up a reverse proxy with IIS7, ARR, & URL Rewrite

风格不统一 提交于 2019-12-11 10:39:31

问题


I'm trying to set up a reverse proxy for a website roughly as outlined in this article: http://blogs.msdn.com/b/carlosag/archive/2010/04/02/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr.aspx

The problem that I'm having is that my outbound rules aren't consistently applied, and I can't find a pattern where they consistently fail either. Sometimes when I restart IIS and make a request the outbound rules successfully applied, other times not. But consistently when I refresh the page the response contains no rewritten urls. Below is the ruleset that I'm using which is equivalent to the ruleset in the link above, so I don't think the rules are the issue. There must be some setting in IIS that I'm missing. This application is currently hosted on my local machine (localhost):

 <system.webServer>
    <rewrite>
        <rules>
            <rule name="Route the requests for blog" stopProcessing="true">
                <match url="^blog/(.*)" />
                <conditions>
                    <add input="{CACHE_URL}" pattern="^(https?)://" />
                </conditions>
                <action type="Rewrite" url="{C:1}://www.mysite.com/{R:1}" />
                <serverVariables>
                    <set name="HTTP_ACCEPT_ENCODING" value="" />
                </serverVariables>
            </rule>
        </rules>
        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://www.mysite.com/(.*)" />
                <action type="Rewrite" value="/blog/{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="/blog/{R:1}" />
            </rule>
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>
    </rewrite>
</system.webServer>

This post was edited to use a simpler ruleset.

来源:https://stackoverflow.com/questions/7139733/problem-with-outbound-rules-when-setting-up-a-reverse-proxy-with-iis7-arr-ur

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!