We often do some server administration job for the server we work on and host our corporate and client sites which are at development. One day we decided to turn GZIP compression on at the server to speed up the HTTP packets downloading. Although it seemed to be a trivial task, but it turned out that a good manual, that could clearly explain how to do it for Nginx on Centos 7, was difficult to find.
Eventually after we have successfully coped with this problem, we decided our experience is going to be useful and set up such a manual.
ngx_http_gzip_module – it’s such a filter that reduce size of transmitted data to twice or more by compressing response with Gzip.
Activate GZIP on Nginx in this file /usr/local/etc/nginx/nginx.conf
# Enable / Disable the gzip compression
# The minimum size of compressing file, in bytes
# Set the buffer size for all proxy requests
# MIME types that should be compressed
# If there are warnings, like "duplicate MIME type text/html", then you should exclude text/html
# It is forbidden to use Gzip compression for IE6
# Level of Gzip compression
Be sure restart the Nginx.
Now if you want to test how Gzip compression is working on Nginx, please follow next.
[[email protected] ~]$ curl --header "Accept-Encoding: gzip,deflate,sdch" -I http://www.scalescale.com/tips/nginx
HTTP/1.1 200 OK
Date: Tue, 26 Feb 2013 15:41:38 GMT
Content-Type: text/html; charset=UTF-8
We hope you would find it useful!