Configuring Gzip in Nginx
The ngx_http_gzip_module module is a filter that compresses responses using gzip, reducing the amount of data transferred by a factor of 2 or more.
Let’s enable GZip in Nginx in the /usr/local/etc/nginx/nginx.conf file:
http {
...
# Включение модуля
gzip on;
# Минимальная длина ответа, при которой модуль будет жать, в байтах
gzip_min_length 1000;
# Разрешить сжатие для всех проксированных запросов
gzip_proxied any;
# MIME-типы которые необходимо жать
#gzip_types text/plain text/html text/xml application/xml application/x-javascript text/javascript text/css text/json;
# Если у вас появляются варнинги, типа "duplicate MIME type text/html", то вам стоит исключить text/html
#gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json;
# Запрещает сжатие ответа методом gzip для IE6
gzip_disable "msie6";
# Уровень gzip-компрессии
gzip_comp_level 8;
...
}
A complete description of all the module’s directives is available at http://sysoev.ru/nginx/docs/http/ngx_http_gzip_module.html.
Don’t forget to restart Nginx!
Comments are closed. Read the original discussion in Russian →
