Reputation: 1
I want to set reverse proxy rules in IIS for list below.
app1.application.com > localhost:26000
app2.application.com > localhost:26001
app3.application.com > localhost:26002
I added bindings in single IIS site then defined single rule for port 26000. All of them redirect to app on port 27000.
Here is the rule I added;
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:26000/{R:1}" />
</rule>
How can I add other rules?
Thanks
Upvotes: 0
Views: 531
Reputation: 467
Like this. Note the 4th rule how I'm doing a temporary redirect to an internet URL. That's an easy way for "testing" your scripts as its a little more foolproof to do Redirect and internal rewrites. Typically I get everything working with Redirects (again, use Temporary) and then switch it over to the internal Rewrites.
Finally, you might consider adding a catch-all rewrite after your 3 to redirect either to an error page or to a "default" app. Since these rules are processed in order (and Stop Processing is set) you can just add that rule without the HTTP_HOST condition at the end.
<rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:26000/{R:1}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(app1\.application\.com)$" />
</conditions>
</rule>
<rule name="ReverseProxyInboundRule2" enabled="true" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:26001/{R:1}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(app2\.application\.com)$" />
</conditions>
</rule>
<rule name="ReverseProxyInboundRule3" enabled="true" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:26002/{R:1}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(app3\.application\.com)$" />
</conditions>
</rule>
<rule name="ReverseProxyInboundRule4" enabled="false" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="http://www.google.com" redirectType="Temporary" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(app4\.application\.com)$" />
</conditions>
</rule>
Upvotes: 2