I'm running a reverse proxy using ARR and URL rewrite v2 beta. So far, the reverse proxy is working fine. I'm trying to setup outbound rules to inspect the HTML response to rewrite any href or src attributes in <a> tags. So far, any request to http://www.proxyserver.com/foo.aspx is routed and rewritten properly to http://www.targetserver.com/foo.aspx. Great!
But somewhere in the html of foo.aspx there is an <a href="http://www.targetserver.com/bar.aspx">Go to bar</a> that I want to be rewritten in an outbound rule as http://www.proxyserver.com/bar.aspx. Is this possible? I've read http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/ and am finding myself stuck on trying to get the pattern to match on host and not path.
Any help on this is much appreciated
Here's my rules so far:
<rewrite>
<rules>
<rule name="Reverse Proxy to target" stopProcessing="true">
<match url="^(.*)" />
<action type="Rewrite" url="https://www.targetserver.com/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="Rewrite URLs in markup" patternSyntax="ECMAScript" stopProcessing="false" preCondition="HTML Only">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" customTags="" pattern="targetserver.com" ignoreCase="true" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
<action type="Rewrite" value="proxyserver.com" />
</rule>
<preConditions>
<preCondition name="HTML Only" logicalGrouping="MatchAny" patternSyntax="ECMAScript">
<add input="{HTTP_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>