NGINX Cheatsheet
An NGINX cheatsheet I made for future me. Information came primarily from Official NGINX Docs.
Ubuntu Installation #
- Update packages
sudo apt-get update
- Install NGINX
sudo apt-get install nginx
- verify installation
sudo nginx -v
Comands #
- Start, restart, and stop NGINX
sudo service nginx start|restart|stop
- Check status
sudo service nginx status
- Test config file
nginx -t
Server Blocks #
Serve Static Content
server {
listen [::]:80;
listen 80;
server_name DOMAIN.COM;
root /path/to/static/files/;
# reverse proxy
location / {
proxy_pass http://127.0.0.1:<PORT_NUMBER>;
}
}
GZIP #
sudo nano /etc/nginx/nginx.conf
- scroll down an uncomment the GZIP settings.
gzip on; gzip_vary on; gzip_min_length 10240; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml; gzip_disable "MSIE [1-6]\.";