Nginx is a high-performance web server and reverse proxy. It handles static files, load balancing, SSL termination, and request routing.
Reverse proxy: proxy_pass forwards requests to backend servers (Node.js, Python). proxy_set_header passes original request headers.
Load balancing: upstream block defines server pools. Algorithms: round-robin (default), least-connections, ip-hash for session persistence.
SSL/TLS: configure certificates with ssl_certificate and ssl_certificate_key. Enable HTTP/2, HSTS, and modern cipher suites.
Performance: gzip compression, brotli (if available), worker_processes set to CPU cores, keepalive connections, and static file caching headers.
Security: rate limiting with limit_req_zone, IP whitelisting, security headers (X-Frame-Options, CSP), and request size limits.
Common configs: redirect HTTP to HTTPS, serve SPA with try_files, proxy WebSocket connections, and cache static assets.