IIS Proxy Production Directives

4 December 2015 by Alexander Bukev

This page will guide you through setting up the Reverse Proxy configuration for Yavli Resilience on IIS.

 

Requirements and prerequisites

  • IIS version 7 or above is required
  • Application Request Routing Version 2 is required
  • URL Rewrite Module Version 2 is required

 

To install ARR 2(it also includes the URL Rewrite Module), please follow this official Microsoft guide:

 

http://www.iis.net/learn/extensions/installing-application-request-routing-%28arr%29/install-application-request-routing-version-2

 

You can also use Microsoft’s Web Platform Installer(WebPI) to install it.

 

Turning on the ARR Proxy

  1. Open the main server dashboard in IIS Manager.
  2. Look for the Application Request Routing Cache icon under the IIS tab and open it.
  3. Click on Server Proxy Settings link on the right sidebar.
  4. Make sure the Enable Proxy checkbox is ticked.
  5. The configuration should look like this:
    HTTP Version: Pass-through
    Keep Alive: Checked
    Time-out: 120 seconds
    Reverse rewrite host in response headers: Checked
    Preserve client IP in the following header: X-Forwarded-For
    Include TCP port from client IP: Checked
    Forwarding proxy header value: Leave blank.
    Memory cache duration: 60 seconds
    Enable disk cache: Checked
    Enable request consolidation: Not checked
    Query string support: Ignore query string
    Response buffer: 4096KB
    Response buffer threshold: 256KB
    Proxy server: Leave blank.
    Use URL Rewrite to inspect incoming requests: Not checked
    

    You are free to optimize the above settings to your needs. The only really important things for us are that the Enable Proxy is checked and that the X-Forwarded-For header is transferred to us.

 

Adding our Reverse Proxy block

Please insert the following configuration inside your website’s web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>

      ...

        <rule name="Yavli Image Proxy Redirect" stopProcessing="true">
          <match url="(.*\.(|jpg|jpeg|gif|png))$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="http://steg.yavli.com/{R:0}" appendQueryString="false" />
        </rule>

      ...

      </rules>
    </rewrite>
  </system.webServer>
</configuration>

 

Although not required, it is recommended to recycle te Application Pool after making the changes.