Chirdeep Tomar
Chirdeep Tomar

Reputation: 4461

HTTP Error 500.52 - URL Rewrite Module Error.

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.

http://www.iis.net/learn/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing

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").

Upvotes: 8

Views: 32652

Answers (4)

techfooninja
techfooninja

Reputation: 195

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:

  1. Through the IIS Manager GUI on the server node in the left pane, navigate to URL Rewrite
  2. Click View Server Variables in the right pane
  3. Add two Allowed Server Variables:
HTTP_ACCEPT_ENCODING
HTTP_X_ORIGINAL_ACCEPT_ENCODING
  1. Back in URL Rewrite options for the Server, click on View Preconditions in the right pane. Add a new precondition (I named it NeedsRestoringAcceptEncoding)
  2. Set the Condition Input to {HTTP_X_ORIGINAL_ACCEPT_ENCODING} and the Pattern to ".+" (no quotes).
  3. On the inbound rewrite rule that is causing the error, add the following to Server Variables (you'll find it underneath the Conditions section):
Server Variable Name: HTTP_X_ORIGINAL_ACCEPT_ENCODING
Value: {HTTP_ACCEPT_ENCODING}

Server Variable Name: HTTP_ACCEPT_ENCODING
Value: ""
  1. On the outbound rewrite rule, add the precondition created from steps 4-5 to the Precondition section of the rule (it should be populated in the drop-down box)

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.

Upvotes: 6

AperioOculus
AperioOculus

Reputation: 6821

Disabling dynamic and static content compression from the site responsible for reverse proxying the requests AND the site that is being proxied fixed this error for me.

To put it in other words - if server X is routing requests to server Y, then disable dynamic and static content compression on the sites on both server X and Y.

Upvotes: 0

yubo
yubo

Reputation: 1

find "compress" in IIS,then remove the dynamic content compression and static content compression.

Upvotes: 0

Rafal Zdziech
Rafal Zdziech

Reputation: 29

Add this to your web config

 <serverVariables>
    <set name="HTTP_ACCEPT_ENCODING" value="" />          
 </serverVariables>

or disable dynamic compression in iis

Upvotes: 0

Related Questions