Skip to content

Instantly share code, notes, and snippets.

@r4hulp
Last active August 29, 2015 14:27
Show Gist options
  • Save r4hulp/4c1bcecc71c372080db3 to your computer and use it in GitHub Desktop.
Save r4hulp/4c1bcecc71c372080db3 to your computer and use it in GitHub Desktop.
Web Config for Reverse Proxy in IIS
<rewrite>
<rules>
<rule name="Route Requests from localhost api to Remote API url" stopProcessing="true">
<match url="^api/(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="https://www.wrapcode.com:1234/api/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
</rules>
<outboundRules>
<rule name="Convert remote API response to localhost API" preCondition="ResponseIsHtmlOrJSON">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://www.wrapcode.com:1234/api/(.*)" />
<action type="Rewrite" value="api/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsJSON">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/json" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment