【发布时间】:2016-03-07 08:38:15
【问题描述】:
我定义了以下入站和出站规则以使我的反向代理正常工作。
<rewrite>
<rules>
<rule name="Route the requests for backend app" stopProcessing="true">
<match url="^foldera/folderb/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.site1.com" />
</conditions>
<action type="Rewrite" url="http://www.site2.com/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
</rules>
<outboundRules>
<rule name="RewriteRelativePaths" preCondition="ResponseIsHtml" enabled="true" stopProcessing="false">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" />
<action type="Rewrite" value="/foldera/folderb/{R:1}" />
<conditions>
<add input="{URL}" pattern="^/foldera/folderb/.*" />
</conditions>
</rule>
<preConditions>
<preCondition name="ResponseIsHtml">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
现在,站点“http://www.site2.com/”已正确加载到“http://www.site1.com/foldera/folderb/”中,并且出站规则确保将站点 2 中的每个资源都重写为 http://www.site1.com/foldera/folderb/{resourcefromsite1} 不幸的是,出站规则也使我网站的其他部分崩溃。可能是因为他试图将每个本机资源重写为相同的“http://www.site1.com/foldera/folderb/”文件夹结构。 如何使出站规则仅响应通过路径 http://www.site1.com/foldera/folderb/ 而不是通过 http://www.site1.com/foldera 请求/加载的资源
干杯 杰伦
【问题讨论】:
标签: iis proxy reverse rule outbound