====== Ubuntu - nginx - Certificate installation ======
Edit the Nginx config file, and fine the gzip section.
Ensure that the gzip options are not commented out - they should not have a hash (#) sign in front of the lines.
. . .
##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
. . .
Nginx can use gzip to compress files it serves on the fly. Those files are then decompressed by the browsers that support it upon retrieval with no loss whatsoever, but with the benefit of smaller amount of data being transferred between the web server and browser.
The **gzip_types** tells Nginx to compress a variety of different file tyoes. If this line was missing then by default Nginx only compresses HTML files and not other files such as images or .css files.
If any changes have been made to the configuration file, then to enable the new configuration, reload Nginx.
sudo systemctl reload nginx
----
===== Check if gzip compression is being used =====
Execute the following command:
curl -H "Accept-Encoding: gzip" -I http://localhost/test.html
This should display several HTTP response headers:
Nginx response headers
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 19 Jan 2016 20:04:12 GMT
Content-Type: text/html
Last-Modified: Tue, 04 Mar 2014 11:46:45 GMT
Connection: keep-alive
Content-Encoding: gzip
In the last line, you can see the **Content-Encoding: gzip header**.
This tells us that gzip compression has been used to send this file.
If this line was missing then gzip is not being used.