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:
date: Tue, 14 Jun 2022 09:55:10 GMT
last-modified: Mon, 13 Jun 2022 16:07:08 GMT
server: nginx/1.15.0 (Ubuntu)
content-encoding: gzip line in the response is the proof that the content is gzipped now.