Run the following command on your Ubuntu’s terminal to open nginx.conf file:
sudo nano /etc/nginx/nginx.conf
Scroll donw to Gzip Settings section in that file:
Add the following line in that section:
Hit CTRL + O and CTRL + ENTER to save the file.
Run the following command to restart the nginx :
sudo service nginx restart
When you access the JS ans CSS files they will be gzipped served from the server. You can verify the response headers:
content-encoding: gzip line in the response is the proof that the content is gzipped now.