Iis – Reverse Proxy on Virtual Directory in IIS7

iisreverse-proxyrewrite

I am running a WHS 2011 and try to proxy an internal webserver (subsonic) over IIS7. The goal is:

https://external_host/subsonic -> http://internal_host:4040

What I've done so far:

  • Created a Virtual Directory "subsonic" in the Default Web Site
  • List item

Created the Rewrite Rules

Whenever I call the URL https://external_host/subsonic I'll get a 404 while trying to access https://external_host/login.view. login.view is in fact the login page of the internal web server.

Here's the config on the Virtual Directory "subsonic":

    <rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://homeserver:4040/{R:1}" />
            </rule>
        </rules>
        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                <match filterByTags="A, Form, Img" pattern="^http(s)?://homeserver:4040/(.*)" />
                <action type="Rewrite" value="http{R:1}://www.external.com/{R:2}" />
            </rule>
        </outboundRules>
    </rewrite>

Is it possible to run a Reverse Proxy on a Virtual Directory at all?

Best Answer

IIS Application Request Routing (ARR) is the perfect solution to this. We are doing this today proxying a public facing domain to an internally hosted web farm. Basically it is using rewrite rules to accomplish this, but it provides a few extra goodies for reverse proxy as well.