Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

HTTP Error 500.52 (gzip compression) when using IIS as a reverse proxy

, 25 Mar 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Markus Greuel

Germany Germany
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 25 Mar 2014
Article Copyright 2014 by Markus Greuel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid