FastAPI · Gunicorn · PM2 · NGINX · SSL · UFW · Fail2Ban · SSH Hardening · AWS Lightsail
Traffic flows through multiple security layers before reaching your FastAPI app:
Internet ↓ AWS Lightsail Cloud Firewall (ports 22, 80, 443) ↓ UFW Firewall (OS-level, Ubuntu) ↓ Fail2Ban (Brute-force / IDS) ↓ NGINX Reverse Proxy (public-facing, 80/443) ↓ Gunicorn + Uvicorn Workers (ASGI app server) ↓ FastAPI Application (127.0.0.1:4980 — localhost only)
127.0.0.1:4980 — never 0.0.0.0. NGINX is the only public entry point.