Click here to Skip to main content
15,881,172 members
Articles / Web Development / IIS

HTTP Error 500.52 (gzip compression) When Using IIS as a Reverse Proxy

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
25 Mar 2014CPOL1 min read 17.7K   1
IIS cannot rewrite gzip compressed responses from another web server, but you can prevent the response from being compressed.

When you want to run multiple web servers on port 80 and one of them is IIS, you can use URL rewriting to setup IIS as a reverse proxy. That's easy enough, you just configure the other web server to listen on a different port (e.g. 8080). Then you add a new rewrite rule in IIS, select reserve proxy and enter the external (port 80) and the internal (8080) and you're done.

However, you might run into an issue if the web server uses compression, as IIS will not be able to rewrite the compressed response:

HTTP Error 500.52 - URL Rewrite Module Error.
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip").

If you can disable compression, problem solved.

But maybe you cannot disable it (or don't know how). I had this issue with Octopus deploy. Maybe there is a hidden config switch to disable compression, but I didn't see any. In this case, you can use the IIS rewrite rule to override the HTTPACCEPTENCODING header before the request is delegated to the other web server.

There are only two smaller hurdles on the way:

  • The IIS Manager UI won't let you set an empty value for the header, so you have to edit it in the web.config.
  • By default, you're not allowed to set the HTTP_ACCEPT_ENCODING header, so you have to allow it. This can be done in the "Allowed Server Variables" menu, which you'll find in the side bar of the "URL Rewrite" feature ("View Server Variables...")

Without the HTTP_ACCEPT_ENCODING header allowing compressed responses, the web server should not use gzip compression and the rewrite should work just fine.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionReverse Proxy to OctopusDeploy Pin
jamgray30-Jan-15 11:10
jamgray30-Jan-15 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.