DangKit
All Cheatsheets

NGINX Cheat Sheet

# NGINX Cheat Sheet ## Basic Config ```nginx server { listen 80; server_name example.com; root /var/www/html; index index.html; } ``` ## Reverse Proxy ```nginx location /api/ { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } ``` ## SSL ```nginx listen 443 ssl; ssl_certificate /path/to/cert.pem; ssl_certificate_key /path/to/key.pem; ssl_protocols TLSv1.2 TLSv1.3; ``` ## Load Balancing ```nginx upstream backend { server 10.0.0.1:3000; server 10.0.0.2:3000; } server { location / { proxy_pass http://backend; } } ``` ## Caching ```nginx proxy_cache_path /tmp/cache levels=1:2 keys_zone=my_cache:10m; location / { proxy_cache my_cache; proxy_cache_valid 200 1h; } ``` ## Rate Limiting ```nginx limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s; location /api/ { limit_req zone=api burst=20; } ```
DangKit โ€” 139+ Free Online Tools: PDF, Dev, Design, Finance & More