Skip to content

Instantly share code, notes, and snippets.

@jordanyaker
Last active June 14, 2019 06:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordanyaker/7534574 to your computer and use it in GitHub Desktop.
Save jordanyaker/7534574 to your computer and use it in GitHub Desktop.
This is a web.config file for doing reverse proxy with the ARR module from IIS. The configuration file was based on instructions from here: http://blogs.iis.net/carlosag/archive/2010/04/01/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr.aspx
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite API" stopProcessing="true">
<match url="^api\/(.*)$" />
<action type="Rewrite" url="https://DESTINATION.COM/{R:1}" />
</rule>
</rules>
<outboundRules>
<preConditions>
<preCondition name="IsRedirect">
<add input="{RESPONSE_STATUS}" pattern="^30[1237]$" />
</preCondition>
</preConditions>
<rule name="API Redirect" preCondition="IsRedirect" enabled="true">
<match serverVariable="RESPONSE_Location" pattern="^(https?)://DESTINATION\.COM/(.*)" />
<conditions>
<add input="{URL}" pattern="^api\/.*$" />
<add input="{HTTP_HOST}" pattern="^api\..*$" negate="true" />
</conditions>
<action type="Rewrite" value="{R:1}://{HTTP_HOST}/api/{R:2}" />
</rule>
<rule name="API Cookies" stopProcessing="true">
<match serverVariable="RESPONSE_SET_COOKIE" pattern=".*" negate="false" />
<conditions>
<add input="{RESPONSE_SET_COOKIE}" pattern="^(ARRAffinity=.*;Domain=)DESTINATION\.COM.*$" />
</conditions>
<action type="Rewrite" value="{C:1}DESTINATION.COM" />
</rule>
</outboundRules>
</rewrite>
<caching enabled="false" enableKernelCache="false" />
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<security>
<requestFiltering>
<verbs>
<add verb="OPTIONS" allowed="false" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment