IIS reverse proxy / re-write rule to redirect requests to another port

iisrewrite

I am attempting to rewrite requests for http://redmine (where IIS is bound) to http://web01:8080/redmine (where apache is bound and ruby is serving redmine). Noet that I also have an A record binding http://intranethome to http://web01:80 and https://web01:443

I've primary used the following for reference:

I believe that the following should work, but it simply isn't:

<rewrite>
<rules>
  <rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="redmine(.*)" />
    <action type="Rewrite" url="http://web01:8080/redmine{R:1}" logRewrittenUrl="true" />
  </rule>
</rules>
<outboundRules>
  <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
    <match filterByTags="A, Form, Img" pattern="^http(s)?://web01:8080/redmine(.*)" />
    <action type="Rewrite" value="http{R:1}://redmine/{R:2}" />
  </rule>
  <preConditions>
    <preCondition name="ResponseIsHtml1">
      <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
  </preConditions>
</outboundRules>
</rewrite>

I've done similar things in apache, but can't seem to understand the issues with IIS. Any input is appreciated.

Best Answer

I realize that you may be looking for a native IIS solution, which I'm sure may exist, but in the past I have done this successfully in enterprise environments using Helicon Ape, which is an Apache .htaccess/module implementation for IIS.

What you are trying to do seems to be easily accomplished using Apache mod_rewrite/mod_proxy in Helicon Ape. This software is always my go-to for IIS rewrites, because ISAPI is a nightmare, and IIS 6 (which we still run on quite a few machines) doesn't support a native rewrite module.

There is a very small amount of configuration when setting up Helicon Ape, such as making sure the IIS group has access to one of the Helicon directories in Program Files, but after that it's a walk in the park, especially if you are already familiar with .htaccess.

In your Default Web Site, you will see httpd.conf, where you will enable mod_rewrite and/or mod_proxy, and then add your specific rules inside the .htaccess in the Helicon Ape module under your specific site.

If decide to go this route and have trouble with configuration, post a follow-up, and I can provide more specific instructions. FYI, Helicon Ape comes with licenses for up to 3 sites per installation.

http://www.helicontech.com/ape/