Your final web.config is missing some of the things that the body of the text defines. For example, for the custom Form Action.
I took your advice re differentiating the ResponseIs* preConditions.
My web.config is below, redacted slightly
So what happens to the usual things like normal A and IMG and SCRIPT? Do they get rewritten with these rules or do I need to explicitly handle them?
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://mysite/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsTextHtml" stopProcessing="false">
<match filterByTags="None" pattern="^http(s)?://mysite/(.*)" />
<action type="Rewrite" value="http{R:1}://theirsite/{R:2}" />
</rule>
<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
</rule>
<rule name="CustomAnchorHref" preCondition="ResponseIsTextAnything">
<match pattern="href=(.*?)https://mysite/(.*?)\s" />
<action type="Rewrite" value="href={R:1}https://theirsite/{R:2} " />
</rule>
<rule name="CustomFormAction" preCondition="ResponseIsTextAnything">
<match pattern="action=(.*?)https://mysite/(.*?)\\" />
<action type="Rewrite" value="action={R:1}https://theirsite/{R:2}\" />
</rule>
<preConditions>
<preCondition name="ResponseIsTextHtml">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
<preCondition name="ResponseIsTextAnything">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
</preCondition>
<preCondition name="NeedsRestoringAcceptEncoding">
<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".*" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>