SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Nginx
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Nginx cheatsheet

Service control

CommandDescription
systemctl status nginxService status
systemctl reload nginxReload config (graceful)
systemctl restart nginxFull restart
nginx -tTest config syntax
nginx -TTest and dump full effective config

Sites (Debian/Ubuntu)

CommandDescription
ln -s .../sites-available/mysite /etc/nginx/sites-enabled/Enable a site
rm /etc/nginx/sites-enabled/defaultDisable default site
ls /etc/nginx/sites-enabled/List enabled sites

Logs and debugging

CommandDescription
tail -f /var/log/nginx/error.logFollow error log
tail -f /var/log/nginx/access.logFollow access log
journalctl -u nginx -fsystemd journal
ss -tlnp | grep nginxCheck listeners
curl -vI -H "Host: www.example.com" http://127.0.0.1/Test vhost locally

Static site server block

server { listen 80; server_name www.example.com; root /var/www/example; index index.html; location / { try_files $uri $uri/ =404; } }

Reverse proxy server block

upstream app_backend { server 127.0.0.1:8000; } server { listen 80; server_name api.example.com; location / { proxy_pass http://app_backend; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

Pro tips

  • Always run nginx -t before reload — syntax errors can prevent startup
  • Use curl -H "Host: ..." to test server blocks without DNS
  • Trailing slash on proxy_pass changes URI rewriting — check the docs
  • nginx -T shows the merged config after all include directives

Practice scenarios

Hands-on Nginx scenarios on live Linux VMs: nginx

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a