How to enable gzip compression on nginx?


2016-11-16 12:55:04 UTC


2017-08-16 16:07:29 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.x for Linux
  • Plesk 12.0 for Linux


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

How to enable it globally?


  1. Connect to the server using SSH.
  2. 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/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
    gzip_vary on;

    Note: This is an example. It is possible to add other file types in gzip_types, e.g. application/javascript , application/js , etc.

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

    # nginx -t
  4. 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.