【发布时间】:2011-11-07 01:37:15
【问题描述】:
我正在使用 IIS 7.5 中的 URL 重写和应用程序请求路由来为需要集成到现有网站的几个博客设置反向代理。多个域绑定到 IIS 中的一个网站,每个域都将获得一个托管在其他地方的博客 - 这就是 ARR 和 URL 重写的来源。我遇到的问题是在我的出站规则集中服务器变量 {HTTP_HOST} 拉内容服务器的主机名,而不是代理服务器的。是否有一个我可以使用的服务器变量会给我代理服务器的主机hame?这是一个博客的规则集,需要澄清一些简短的 cmets:
<rewrite>
<rules>
<rule name="Route requests for contentserver blog" stopProcessing="true">
<match url="^blog/(.*)" />
<conditions trackAllCaptures="true">
<add input="{CACHE_URL}" pattern="^(https?)://" />
<add input="{HTTP_HOST}" pattern="(www\.)proxyserver\.com$" /> <!--this works-->
</conditions>
<action type="Rewrite" url="{C:1}://blog.contentserver.com/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite Relative URLs" preCondition="ResponseIsHtml" stopProcessing="true">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" negate="false" />
<action type="Rewrite" value="/blog/{R:1}" />
<conditions>
<add input="{URL}" pattern="^/blog/" />
<add input="{HTTP_HOST}" pattern="^(www\.)proxyserver\.com$" /> <!--this doesnt work because it's grabbing the content server's host, not the proxy server's host-->
</conditions>
</rule>
<rule name="Rewrite Absolute URLs" preCondition="ResponseIsHtml" stopProcessing="true">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^(https?)://blog\.contentserver\.com(/(.*))?" />
<action type="Rewrite" value="/blog/{R:3}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)proxyserver\.com$" /> <!--this doesnt work because it's grabbing the content server's host, not the proxy server's host-->
<add input="{URL}" pattern="^/blog/" />
</conditions>
</rule>
<preConditions>
<preCondition name="ResponseIsHtml">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
在我弄清楚这一点之前,我只是要确保博客 url 是唯一的,即 proxyserversite1/blog1 和 proxyserversite2/blog2,但我希望能够在出站规则中获取代理服务器主机,所以我可以将它们命名为 proxyserversite1/blog 和 proxyserversite2/blog 。有什么想法吗?
【问题讨论】:
标签: iis-7 url-rewriting