# Nginx not gzipping php output

**URL:** <https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520>\
**Category:** NGINX\
**Created:** [September 6, 2011, 3:13pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520 "2011-09-06T15:13:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 6, 2011, 3:13pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520/1 "2011-09-06T15:13:22Z")

</div>

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:

> **[nginx not gzipping php output](https://forum.nginx.org/read.php?2,214879,214879#msg-214879)**
>
> 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)...

---

<div class="post-metadata">

**Author:** ![djeyewater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@djeyewater](https://www.ruby-forum.com/u/djeyewater)\
**Post date:** [September 6, 2011, 3:34pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520/2 "2011-09-06T15:34:24Z")

</div>

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:

> **[Re: nginx not gzipping php output](https://forum.nginx.org/read.php?2,214879,214881#msg-214881)**
>
> 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)...

---

<div class="post-metadata">

**Author:** ![djeyewater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@djeyewater](https://www.ruby-forum.com/u/djeyewater)\
**Post date:** [September 6, 2011, 3:56pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520/3 "2011-09-06T15:56:02Z")

</div>

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:

> **[Re: nginx not gzipping php output](https://forum.nginx.org/read.php?2,214879,214885#msg-214885)**
>
> 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)...

---

<div class="post-metadata">

**Author:** ![djeyewater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@djeyewater](https://www.ruby-forum.com/u/djeyewater)\
**Post date:** [September 6, 2011, 4:32pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520/4 "2011-09-06T16:32:00Z")

</div>

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:

> **[Re: nginx not gzipping php output](https://forum.nginx.org/read.php?2,214879,214890#msg-214890)**
>
> 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)...

---

<div class="post-metadata">

**Author:** ![djeyewater](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71e660/32.png) [@djeyewater](https://www.ruby-forum.com/u/djeyewater)\
**Post date:** [September 6, 2011, 4:27pm UTC](https://www.ruby-forum.com/t/nginx-not-gzipping-php-output/211520/5 "2011-09-06T16:27:40Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
