How to enable gzip compression on nginx


2016-11-16 12:55:04 UTC


2017-05-21 10:19:38 UTC


Was this article helpful?

Have more questions?

Submit a request

How to enable gzip compression on nginx

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux


ngx_http_gzip_module module is a filter that compresses responses using the gzip method. This often helps to reduce the size of transmitted data by half or even more.

How to enable it?


  1. Create a file using the command ' vi /etc/nginx/conf.d/gzip.conf ' and put the following content in it:

    gzip         on;
    gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
    gzip_vary on;

    This is an example. It is possible to add in gz_types - application/javascript , application/js , etc.

  2. Test the configuration and fix errors (if any):

    # nginx -t
  3. Reload nginx configuration:

    # service nginx reload

Other gzip_types available for compression can be obtained from /etc/nginx/mime.types .

If it is needed to enable this module for a single domain, add the aforementioned content in the Domains > > Apache & nginx Settings > Additional nginx directives.

More about gzip compression module can be found in nginx manual .

Have more questions? Submit a request


Please sign in to leave a comment.