S
Supanote
Sign in Sign up

Nginx WebSocket Reverse Proxy Configuration

plain (nginx) 1 month ago · 36 lines · 226 views
Verified Blueprint Nginx

Production reverse proxy configuration with WebSocket upgrade headers, HTTP/1.1 keepalive, and timeout tuning.

Quick Fetch
1# Nginx Reverse Proxy with Full WebSocket Support
2map $http_upgrade $connection_upgrade {
3 default upgrade;
4 '' close;
5}
6
7upstream websocket_backend {
8 server 127.0.0.1:4000;
9 keepalive 64;
12server {
13 listen 443 ssl http2;
14 server_name ws.example.com;
16 ssl_certificate /etc/letsencrypt/live/ws.example.com/fullchain.pem;
17 ssl_certificate_key /etc/letsencrypt/live/ws.example.com/privkey.pem;
18 ssl_protocols TLSv1.2 TLSv1.3;
20 location / {
21 proxy_pass http://websocket_backend;
22 proxy_http_version 1.1;
23 proxy_set_header Upgrade $http_upgrade;
24 proxy_set_header Connection $connection_upgrade;
25 proxy_set_header Host $host;
26 proxy_set_header X-Real-IP $remote_addr;
27 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28 proxy_set_header X-Forwarded-Proto $scheme;
30 # WebSocket Timeout Tuning (prevent premature disconnection)
31 proxy_read_timeout 86400s;
32 proxy_send_timeout 86400s;
33 proxy_connect_timeout 75s;
34 }

No replies yet

Every reply is a note. Start a discussion, ask a question, or attach a code snippet.

Related Nginx & DevOps & Infrastructure Blueprints

Production-ready configurations and diagnostics from the verified Supanote library.

All DevOps & Infrastructure →
Interactive Developer Workbench: Nginx Access & Error Log Analyzer

Parse Nginx combined access logs and upstream error traces instantly with HTTP status colorizing and secret scanning.

Open Nginx Log Analyzer →

Share Note

Open
Download SVG
Social Card Preview
Open on mobile
Point your phone camera to open this note directly

Report this note

Notification