Настройка GZIP сжатия данных сайта

Пример конфигурации

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
 
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 
    access_log  /var/log/nginx/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    keepalive_timeout  65;
 
    client_max_body_size 256M;
 
    gzip  on;
    gzip_min_length  1000;
    gzip_proxied     any;
    gzip_types       text/plain application/xml application/x-javascript text/javascript text/css text/json application/javascript application/font-woff application/octet-stream font/woff2 application/x-shockwave-flash;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_comp_level  5;
    gzip_buffers 64 8k;
    gzip_http_version 1.1;
    gzip_static  on;
    gzip_proxied expired no-cache no-store private auth;
 
    fastcgi_connect_timeout 256s;
    fastcgi_read_timeout 256s;
    fastcgi_send_timeout 256s;
 
    include /etc/nginx/conf.d/*.conf;
}

Основной блок настроек сжатия

http {
 
    # ...
 
    gzip  on;
    gzip_min_length  1000;
    gzip_proxied     any;
    gzip_types       text/plain application/xml application/x-javascript text/javascript text/css text/json application/javascript application/font-woff application/octet-stream font/woff2 application/x-shockwave-flash;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_comp_level  5;
    gzip_buffers 64 8k;
    gzip_http_version 1.1;
    gzip_static  on;
    gzip_proxied expired no-cache no-store private auth;
 
    # ...
}