Reverse Proxy · 10 stack presets

Nginx Reverse Proxy & WebSocket Builder

Choose an application runtime or Docker architecture below. Each preset generates a complete server block with Certbot SSL, WebSocket upgrade headers, and URI rewrite previews.

All 10 Nginx Reverse Proxy Architectures

10 static guides
Next.js / Node.jsWebSockets

Nginx Reverse Proxy Config for Next.js SSR (App Router, SSL & Streaming)

Generate a production Nginx reverse proxy for Next.js App Router on port 3000 with Certbot SSL, _next/static caching, streaming responses, and WebSockets.

Route: / → 127.0.0.1:3000
Limits: 10M · 120s
Build Nginx Config
Python / FastAPIWebSockets

Nginx Reverse Proxy Config for FastAPI + Uvicorn (SSL, Docs & Timeouts)

Build a hardened Nginx reverse proxy config for Python FastAPI and Uvicorn/Gunicorn on port 8000 with --proxy-headers, SSL, WebSockets, and long timeouts.

Route: / → 127.0.0.1:8000
Limits: 50M · 120s
Build Nginx Config
PHP / Laravel OctaneWebSockets

Nginx Reverse Proxy Config for Laravel Octane & Reverb WebSockets

Configure Nginx reverse proxy for Laravel Octane (FrankenPHP/Swoole) on port 8000 and Laravel Reverb WebSockets on port 8080 with SSL and 3600s timeouts.

Route: / → 127.0.0.1:8000
Limits: 50M · 3600s
Build Nginx Config
Node.js / Express

Nginx Reverse Proxy Config for Node.js Express & PM2 (trust proxy & SSL)

Generate a production Nginx reverse proxy for Node.js Express and PM2 on port 4000 with trust proxy, real client IP headers, Certbot SSL, and rate-limit safety.

Route: /api/ → 127.0.0.1:4000
Limits: 10M · 60s
Build Nginx Config
WebSockets / Socket.IOWebSockets

Nginx Reverse Proxy Config for Socket.IO & WebSockets (Upgrade & 3600s)

Fix WebSocket 400 errors and 60-second disconnects in Nginx for Socket.IO and ws servers. Generate Upgrade, Connection map, and 3600s proxy_read_timeout blocks.

Route: /socket.io/ → 127.0.0.1:4000
Limits: 10M · 3600s
Build Nginx Config
Docker Compose / NginxWebSocketsDocker DNS

Nginx Reverse Proxy for Docker Compose Services (127.0.0.11 DNS Resolver)

Prevent 502 Bad Gateway and Nginx startup crashes in Docker Compose using resolver 127.0.0.11 and variable proxy_pass for dynamic container restarts.

Route: /api/ → backend:8000
Limits: 50M · 120s
Build Nginx Config
Python / Django

Nginx Reverse Proxy Config for Django + Gunicorn (SSL, Static & CSRF)

Generate a production Nginx reverse proxy for Django and Gunicorn on port 8000 with SECURE_PROXY_SSL_HEADER, CSRF_TRUSTED_ORIGINS, /static/, and /media/.

Route: / → 127.0.0.1:8000
Limits: 50M · 120s
Build Nginx Config
.NET / ASP.NET CoreWebSockets

Nginx Reverse Proxy Config for ASP.NET Core Kestrel (Forwarded Headers & SignalR)

Build a production Nginx reverse proxy for ASP.NET Core 8/9 Kestrel on port 5000 with UseForwardedHeaders, SignalR WebSockets, SSL, and large OAuth headers.

Route: / → 127.0.0.1:5000
Limits: 50M · 3600s
Build Nginx Config
React Vite + APISPA + API

Nginx Config for React (Vite) SPA + Same-Origin /api/ Proxy (Zero CORS)

Serve a built React Vite dist/ SPA at / with try_files history fallback while proxying /api/ to your backend on the same Nginx domain to eliminate CORS.

Route: /api/ → 127.0.0.1:8000
Limits: 50M · 120s
Build Nginx Config
Microservices / GatewayWebSocketsDocker DNS

Nginx Multi-Service Subpath Routing Config (/api/, /auth/ & /ws/)

Route /api/, /auth/, and /ws/ microservices to separate backend ports under one Nginx HTTPS domain. Master trailing-slash prefix stripping and prevent 404s.

Route: /api/ → api_service:8000
Limits: 50M · 120s
Build Nginx Config

Critical Nginx Reverse Proxy Rules Checked by OpsCheck

Debugging browser CORS too? Open CORS Simulator →

1. Trailing Slash URI Rewriting

Adding a trailing slash to proxy_pass http://host:port/; strips the matched location prefix (/api/users → /users), whereas omitting it preserves the full path.

2. Docker DNS Stale-IP Prevention

Static container hostnames cache once at boot and cause 502 Bad Gateway after restarts. Pair resolver 127.0.0.11 with a variable-based proxy_pass $upstream_endpoint.

3. WebSocket Upgrades & Timeouts

Real-time sockets require proxy_http_version 1.1, the $connection_upgrade map, and extended proxy_read_timeout (e.g., 3600s) to prevent 60-second drops.