Nginx Configuration Cheat Sheet — Reverse Proxy & SSL Directives

Ready-to-use Nginx server blocks for reverse proxying Node/Python apps, SSL Let's Encrypt termination, SPA routing, and gzip compression.

Reverse Proxy & SPA Routing

proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;

Forward HTTP requests to backend Node/Python application preserving client IP

try_files $uri $uri/ /index.html;

SPA fallback routing: serve static assets if exist, else route to React/Vue index.html

client_max_body_size 50M;

Allow file uploads up to 50 Megabytes (default is restrictive 1MB)

nginx -t && systemctl reload nginx

Test configuration syntax before gracefully reloading server without dropping traffic

Performance & SSL Hardening

gzip on; gzip_types text/plain text/css application/json application/javascript;

Enable on-the-fly Gzip compression for text, CSS, JSON, and JS payloads

return 301 https://$host$request_uri;

Permanent 301 redirect all unencrypted HTTP traffic to HTTPS