Gzipping proxied content after using subs_filter fails

abstein2 nginx-forum at nginx.us
Thu Aug 9 21:28:06 UTC 2012

As the title says, I'm having an issue with gzipping proxied web pages
after using subs_filter. It doesn't always happen, but it looks like
whenever a page exceeds the size of one of my proxy_buffers I get an
error in the error log saying:

[alert] 18544#0: *490084 deflate() failed: 2, -5 while sending to
client, client: xxx.xxx.xxx.xxx, server: www.test.com, request: "GET /
HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:80/", host: "www.test.com",
referrer: "http://xxx.xxx.xxx.xxx/"

The page, without any compression, is roughly 80k. When I boost my
proxy_buffers to 100k the page loads fine. When it is below the 80k of
the page, I only receive a partial version of the page (roughly 5k,
whether proxy_buffer_size is set to 4k or 8k).

Turning off gzip serves the entire page as does disabling the
subs_filter commands.

Is there any workaround/fix for this outside of just boosting the
proxy_buffers value so that it exceeds every possible text/html page I'm

In case they're helpful, my normal proxy and gzip settings are:

proxy_cache_use_stale updating error timeout invalid_header http_500
http_502 http_504;
proxy_cache_valid 60m;
proxy_redirect off;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;
proxy_buffers 8 16k;
proxy_buffer_size 16k;
proxy_busy_buffers_size 64k;
proxy_cache_key $host$request_uri$is_args$args;

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 8;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.*SV1)";


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,229545,229545#msg-229545

More information about the nginx mailing list