How to enable/disable gzip compression in nginx on a Plesk server




  • Avatar
    Markus Wernecke

    Thanks a lot! Great 'n' easy tutorial.

  • Avatar

    Isn't text/html most important ? It is missing from the code.

  • Avatar
    Ekaterina Babenko


    Hello Adrian! According to nginx official documentation, for the option gzip_types the mime-type text/html type is always compressed by default, so there is no need to specify it explicitly.
    You can check right here:

  • Avatar

    Is there any disadvantages to enable gzip globally? We often have reqests if we can enable gzip - there i want to insert this globally. 

    But will this harm any Websites in whatever way? Or is failproved ?

  • Avatar
    Ivan Postnikov


    When compressing is enabled, additional server RAM & CPU resources are utilized to compress websites content on the fly. If there are many websites on the server, the load may increase dramatically.

  • Avatar

    @Ivan uff. We have 300 Websites on a Server. Theres 64GB RAM. 

    Any example how i can determine if this will work or not? 

  • Avatar
    Robert Asilbekov

    @Lenor  If you mean how enabling gzip compression affect server performance - the only way is to monitor the server performance. Establish some performance baseline before enabling and see how the baseline will be changed after enabling gzip. 


    If you want to check whether gzip compression works you may use curl command. When gzip enabled you will see in the output 'Content-Encoding: gzip'. You can check individual files instead of pages to ensure they have been gzipped as well.

     #  curl -s -H "Accept-Encoding: gzip" -I http://domain.tld | grep Content-Encoding
    Content-Encoding: gzip

  • Avatar
    Berat Gashi

    Hi there,

    I need help on this one,

    I have a Plesk Server but the Additional nginx Directives is not showing at all even from the admin account!


    Plesk Info:

    OS Ubuntu 18.04.2 LTS
    Product Plesk Onyx 
    Version 17.8.11 Update #39
  • Avatar
    Ivan Postnikov

    Hello @Berat,

    Most probably this is because Nginx is not installed or disabled on your server.

    This article should help:

  • Avatar
    Steve Yates

    I think the mime type for RSS should be application/rss+xml instead of application/xml+rss?

  • Avatar
    Alisa Kasyanova

    @Steve Yates
    Thank you for pointing it out! I have changed the article accordingly.

  • Avatar
    Markus Wernecke (Edited )

    Hi Plesk Team,

    somewhere in Plesk Forums I got the information to set the serverwide nginx gzip configuration in the http section of /etc/nginx/nginx.conf. Is it correct or is it better like in your example for some reasons? I use ONLY NGINX (no Apache / no Proxy) for webhosting.

    http {


    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_http_version 1.1;
    gzip_min_length 100;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml text/javascript image/x-icon image/bmp image/svg+xml application/javascript application/js application/xhtml+xml application/rss+xml application/x-font-ttf application/ font/opentype font/ttf font/eot font/otf image/jpg image/jpeg image/png image/gif application/json;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";



  • Avatar
    Konstantin Annikov (Edited )


    Yes, you can define all the settings in main configuration file and they will work for all hosted websites. There are no known reasons to not to do it.
    However defining additional directives in separate file (in article it is /etc/nginx/conf.d/gzip.conf) is like a best practice for nginx.

Please sign in to leave a comment.

Have more questions? Submit a request