1

我一直在使用 ARR 和重写规则来轻松访问我的 Tomcat 应用程序。

就像应用程序运行在:http://localhost:8090/alfresco

在重写规则之后,它可以通过以下方式访问:http://localhost/alfresco

这是我一直在使用的完美的重写规则示例:

<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
    <match url="(alfresco.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{CACHE_URL}" pattern="^(http?)://" />
    </conditions>
    <action type="Rewrite" url="{C:1}://localhost:8090/{R:1}" />
</rule>

现在我面临的问题是我有另一个本地服务器,它具有相同的 tomcat 应用程序名称和端口。现在我想制定一个重写规则,以便当我访问时:http://localhost/alfresco1

它应该带我到那个服务器,它的 url 是:http://172.23.1.168:8090/alfresco

4

1 回答 1

1

您可以使用以下配置:

<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
    <match url="^(alfresco)1/?(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{CACHE_URL}" pattern="^(http?)://" />
    </conditions>
    <action type="Rewrite" url="{C:1}://172.23.1.168:8090/{R:1}/{R:2}" />
</rule>
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
    <match url="^(alfresco)/?(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{CACHE_URL}" pattern="^(http?)://" />
    </conditions>
    <action type="Rewrite" url="{C:1}://localhost:8090/{R:0}" />
</rule>

它能做什么:

  • 如果 url 以 开头alfresco1,它会将其重写为http://172.23.1.168:8090/alfresco/requested_path使用 the{R:1}{R:2} back 引用
  • 如果 url 以 开头alfresco,它会将其重写为http://localhost:8090:8090/alfresco/requested_path使用匹配的字符串反向引用

此配置基于以下事实

规则的评估顺序与它们指定的顺序相同

在配置文件中定义规则的顺序很重要。

于 2013-06-20T14:23:35.223 回答