Apache’s mod_fastcgi and mod_deflate troubles

Mattias Geniar, Monday, December 8, 2014

There's a very old outstanding but in Apache's mod_fastcgi combined with mod_deflate, where the Content-Length header is not being passed along properly between the FastCGI process (like PHP) and the compression performed by mod_deflate.

The problem occurs when your Apache webserver is running gzip compression via mod_deflate on the content, which is then being passed via mod_fastcgi to an upstream (like PHP) that tries to handle compression as well. In the case of a Drupal system, this can happen when you let Drupal handle gzip-compression via its Performance settings as well as Apache via its mod_deflate module.

And if you search the interwebs, you'll find lots of reports on this;

These all go way back, to beyond 2010. So it's safe to say, this problem has been around for some time. The suggestions to upgrade to the latest version of FastCGI don't seem to help either, at least not on my test-system.

My current workaround was just to disable mod_deflate entirely in Apache, and handle the Gzip compression in another service (like Varnish as HTTP cache or in Nginx as my SSL terminator). This is far from pretty, but it got the job done. For now.

If anyone has any clues why mod_deflate together with mod_fastcgi can cause these headaches, I'd love to hear your thoughts and ideas.



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. Currently working on DNS Spy. Follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

Adam Friday, December 11, 2015 at 15:25

I used to have this problem as well – but I just tried enabling mod_deflate on an Apache that runs a FastCGI application on Ubuntu 12.04 (libapache2-mod-fastcgi version 2.4.7~0910052141-1), and when mod_deflate is enabled, no Content-Length header is sent – so it seems that the problem of sending a wrong Content-Length header has been solved, at least in that version.

Reply


Leave a Reply

Your email address will not be published. Required fields are marked *