• Breaking News

    How to enable gzip on nginx

    Here you have a super easy guide to enable gzip on nginx



    1. Make Sure Gzip module is installed with nginx

    2>&1 nginx -V | tr -- - '\n' | grep _module | grep gzip

    The expected output should be: http_gzip_static_module

    2. Update the host configuration file under the server block entry


    gzip on;
    gzip_disable "msie6";
    
    gzip_comp_level 6;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_proxied any;
    gzip_types
        text/plain
        text/css
        text/js
        text/xml
        text/javascript
        application/javascript
        application/x-javascript
        application/json
        application/xml
        application/rss+xml
        image/svg+xml/javascript;

    3. Reload the nginx configuration


    service nginx reload;

    4. Testing


    curl -H "Accept-Encoding: gzip" -I https://smartit.ninja/

    And the expected output: 

    HTTP/1.1 200 OK
    Server: nginx/1.15.9
    Date: Sat, 18 May 2019 03:50:09 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Last-Modified: Fri, 17 May 2019 15:05:47 GMT
    ETag: W/"1074-58916b7ac32cd"
    Content-Encoding: gzip
    

    That's all folks!


    No comments