Nginx not gzipping php output

Nginx isn’t gzipping php pages, but I don’t know why? I’m using the
Audits tab in Google Chrome Developer tools to determine that the pages
aren’t being gzipped.

My config:
nginx version: nginx/0.8.52
built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
configure arguments: --prefix=/home/djeyewater/apps/nginx
–with-pcre=/home/djeyewater/tarballs/pcre-8.10
–without-http_autoindex_module --without-http_charset_module
–without-http_empty_gif_module --without-http_geo_module
–without-http_ssi_module --with-http_gzip_static_module
–with-http_realip_module --with-http_geoip_module --with-cc-opt=‘-I
/home/djeyewater/apps/GeoIP/include’
–with-ld-opt=‘-Wl,-R,/home/djeyewater/apps/GeoIP/lib -L
/home/djeyewater/apps/GeoIP/lib’

And http section from the .conf file:
http {
include mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;

sendfile on;
keepalive_timeout 10 10;

port_in_redirect off;

#Fix IP address
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;

gzip on;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xhtml+xml application/xml+rss
text/javascript;
gzip_disable “MSIE [1-6].”;

geoip_country /home/djeyewater/apps/GeoIP/share/GeoIP/GeoIP.dat;

log_format main '$remote_addr - $remote_user [$time_local] ’
'“$request” $status $body_bytes_sent “$http_referer” ’
‘“$http_user_agent”’;

include sites/*;
}

Thanks

Dave

Posted at Nginx Forum:

Check your PHP output header for “Content-Type”, if it is not text/html
and one of the gzip_types, it won’t be compress. Your config I have
tested on my server, it will compress normally.

MagicBear

Posted at Nginx Forum:

Thanks for testing it MagicBear.

Google Chrome reports content type header as:
Content-Type:text/html; charset=UTF-8

So still not sure why it is not working.

I checked nginx changelog and couldn’t see anything that looked to be
pointing out that this was an issue in older versions of nginx. Still, I
will try latest stable version and see if that makes any difference.

Dave

Posted at Nginx Forum:

Hmm… well I installed the latest version and found that actually
nothing is being zipped. Was probably the same thing before, but most of
the static files have gzip versions and so were included by gzip_static,
making it look like only PHP wasn’t being zipped.

Any ideas?

Posted at Nginx Forum:

In fact, you can try to open php internal gzip compress function, you
may
find it at php.ini, change this to On
zlib.output_compression = Off
and php will compress it auto before send to nginx.

MagicBear

2011/9/6 djeyewater [email protected]