Reputation: 698
I have been using ARR and rewrite rules to easily access my Tomcat application.
Like if the application is running at: http://localhost:8090/alfresco
After the rewrite rule it can be accessed on: http://localhost/alfresco
Here is an example of the rewrite rule I have been using that works perfect:
<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>
Now the problem I am facing is that I have another local server which has this same tomcat application name and port. Now I want to develop a rewrite rule so that when I visit: http://localhost/alfresco1
it should take me to that server which url is: http://172.23.1.168:8090/alfresco
Upvotes: 1
Views: 1004
Reputation: 11762
You could use the following configuration:
<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>
What it does:
alfresco1
, it rewrites it to http://172.23.1.168:8090/alfresco/requested_path
using the {R:1}
and {R:2}
back references.alfresco
, it rewrites it to http://localhost:8090:8090/alfresco/requested_path
using the matched string back reference.This configuration is based on the fact that:
The rules are evaluated in the same order in which they are specified
The order the rules are defined in the configuration file is important.
Upvotes: 1