How to enable the gzip/deflate in nginx server on Linux or Unix system

Originally published at: https://www.cyberciti.biz/faq/how-to-enable-the-gzipdeflate-in-nginx-server-on-linux-or-unix-system/

I am a new Linux system admin and how can I enable gzip compression on nginx web server for JS/CSS/HTML files? How can I enable gzip/deflate in Nginx on Ubuntu Linux server? How do I configure gzip compression with NGINX on FreeBSD Unix server?