I am trying to setup a reverse proxy with IIS 7.5. I want an incoming request that matches a certain URL pattern to be served by Tomcat. I have used the tutorial here to configure it.
My settings are as below:
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url=".*/(Locations|FacetedSearch|LocationPage)/.*" />
<action type="Rewrite" url="http://search.xxx.com/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" replace="true" />
</serverVariables>
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^http(s)?://search.xxx.com/(.*)" />
<action type="Rewrite" value="http{R:1}://dev.xxx.com/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<tracing>
HTTP Error 500.52 - URL Rewrite Module Error. Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("deflate").
I just hit this issue as well, and I found this solution helpful: https://www.saotn.org/iis-outbound-rules-with-gzip-compression/
Basically, on inbound requests the HTTP_ACCEPT_ENCODING header gets stashed into a temporary header, and then gets restored back on the outbound rewrite rule.
In the case the link goes dead, here's the steps:
HTTP_ACCEPT_ENCODING HTTP_X_ORIGINAL_ACCEPT_ENCODING
Server Variable Name: HTTP_X_ORIGINAL_ACCEPT_ENCODING Value: {HTTP_ACCEPT_ENCODING} Server Variable Name: HTTP_ACCEPT_ENCODING Value: ""
In the case that you only need this functionality on a single site, you can add the precondition at the site-level instead of the server-level.