}

How to enable nginx enable gzip

Created:

In this short tutorial we are going to learn how to enable gzip compression

Open the nginx configuration file /etc/nginx/nginx.conf with sudo:

sudo nano /etc/nginx/nginx.cong eval(ez_write_tag([[300,250],'tutorials_technology-medrectangle-3','ezslot_0',114,'0','0'])); Inside the http section append the following lines:

gzip on; gzip_disable "msie6"; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

In our gzip_types section we included css, json, xml and javascript to use gzip compression. The gzip_disable uses a regex on the user agent, we added this line since nginx could crash with msie6, check here the official doc on gzip_disable.

finally restart the server:

sudo service nginx restart

More options that you can add to the configuration:

gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1;

You can se more options on the compression of the responses, check here all the options available.eval(ez_write_tag([[468,60],'tutorials_technology-medrectangle-4','ezslot_1',136,'0','0']));