Web.config Reverse proxy setup for IIS with URL Rewrite

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”ReverseProxyInboundRule1″ stopProcessing=”true”>
<match url=”(.*)” />
<action type=”Rewrite” url=”https://<intranet.app>/{R:1}” />
<serverVariables>
<set name=”HTTP_X_ORIGINAL_ACCEPT_ENCODING” value=”{HTTP_ACCEPT_ENCODING}” />
<set name=”HTTP_ACCEPT_ENCODING” value=”” />
</serverVariables>
</rule>
</rules>
<outboundRules>
<clear />
<rule name=”RestoreAcceptEncoding” preCondition=”NeedsRestoringAcceptEncoding”>
<match serverVariable=”HTTP_ACCEPT_ENCODING” pattern=”^(.*)” />
<conditions logicalGrouping=”MatchAll” trackAllCaptures=”true” />
<action type=”Rewrite” value=”{HTTP_X_ORIGINAL_ACCEPT_ENCODING}” />
</rule>
<rule name=”ReverseProxyOutboundRule1″ preCondition=”ResponseIsHtml1″>
<match filterByTags=”A, Form, Img” pattern=”^http(s)?://https://<intranet.app>/(.*)” />
<conditions logicalGrouping=”MatchAll” trackAllCaptures=”true” />
<action type=”Rewrite” value=”https{R:1}://<internet.app>/{R:2}” />
</rule>
<preConditions>
<preCondition name=”ResponseIsHtml1″>
<add input=”{RESPONSE_CONTENT_TYPE}” pattern=”^text/html” />
</preCondition>
<preCondition name=”NeedsRestoringAcceptEncoding”>
<add input=”{HTTP_X_ORIGINAL_ACCEPT_ENCODING}” pattern=”.+” />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>

Advertisements

One Response to Web.config Reverse proxy setup for IIS with URL Rewrite

  1. guozspace says:

    Good article for setting up reverse proxy K2 Smartforms: https://blog.jikai.sg/setup/7/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s