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 rewrit开发者_JS百科ten 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.
精彩评论