A
Aura DevNginx Cheatsheet
Nginx configuration and commands.
Basic Commands
Service Management
sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl reload nginx sudo systemctl status nginx
Configuration Testing
sudo nginx -t # Test config sudo nginx -T # Test & dump config
Server Blocks (Virtual Hosts)
Basic HTTP Server
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}Reverse Proxy
Proxy Pass
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}Redirects & Security
HTTP to HTTPS Redirect
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}Basic Auth
location /admin {
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}What is Nginx?
Nginx is a high-performance web server, reverse proxy, and load balancer widely used to serve modern web applications.
This cheatsheet provides quick access to common Nginx configuration directives, server blocks, and command-line utilities.
Sponsored LinkAdvertisement Space (728x90)