Skip to main content
← All 10 Production Configurators
EDGE & NETWORKING · NGINX.CONF · LIVE MISCONFIGURATION PHYSICS

NGINX Reverse Proxy & 502 Keepalive Calculator

Generate production-hardened NGINX 1.25+ nginx.conf with TLS 1.3, upstream keepalive race detection (HTTP 502), inward-shrinking timeouts, and 429 rate limiting.

Production-Hardened Edge Proxy
Clean timeout hierarchy (5s), safe keepalive margin (55s < 65s), TLS 1.3 active, and 1200 r/s 429 protection.
REAL-WORLD KNOBS (6)
4096
Max simultaneous open sockets per worker (2 sockets per proxied request).
55s
Must stay BELOW upstream idle timeout or Nginx reuses half-closed sockets → random HTTP 502s.
65s
FastAPI/Uvicorn/Node/Go keep-alive timeout on the backend app server.
5s
Inward-shrinking hierarchy: Edge 5s > App 4s > DB 3s prevents zombie requests.
1200r/s
Token-bucket limit_req_zone with HTTP 429 protects app pools from L7 floods.
Cuts TLS handshake from 2-RTT to 1-RTT and drops legacy weak ciphers.
nginx.conf · PARSER-VERIFIED
worker_processes auto;
events {
  use epoll;
  worker_connections 4096;
}

http {
  limit_req_zone $binary_remote_addr zone=edge_api:10m rate=1200r/s;
  limit_req_status 429;

  upstream app_backend {
    server app:8000 max_fails=3 fail_timeout=10s;
    keepalive 64;
    keepalive_timeout 55s; # Must stay < upstream app idle (65s)
  }

  server {
    listen 443 ssl;
    http2 on;
    ssl_protocols TLSv1.3;
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;

    location /api/ {
      limit_req zone=edge_api burst=240 nodelay;
      proxy_pass http://app_backend;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      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;
      proxy_connect_timeout 2s;
      proxy_read_timeout 5s;
      proxy_next_upstream error timeout http_502 http_503 http_504;
      proxy_next_upstream_tries 2;
    }
  }
}
EXPLORE THIS COMPONENT IN ARCHOS STUDIO
Simulate Full Topology in ArchOS ↗60-Sec L4–L7 Diagnostic →
MATCHING PRODUCTION INCIDENT PLAYBOOKS
M05 · P1 · L6Intermittent Nginx HTTP 502 Bad Gateway from Upstream Keep-Alive RaceRead Incident Playbook →M05 · P1 · L6Linux SYN Backlog Drops, Ephemeral Port Exhaustion & TCP BBRRead Incident Playbook →