Always terminate TLS at your reverse proxy, disable proxy buffering, and set read timeouts higher than heartbeatIntervalMs + heartbeatTimeoutMs (minimum 75s).
1map $http_upgrade $connection_upgrade {1 default upgrade;1 '' close;1}11server {1 listen 80;1 server_name realtime.example.com;1 return 301 https://$host$request_uri;2}22server {1 listen 443 ssl http2;2 server_name realtime.example.com;31 ssl_certificate /etc/letsencrypt/live/realtime.example.com/fullchain.pem;1 ssl_certificate_key /etc/letsencrypt/live/realtime.example.com/privkey.pem;1 ssl_protocols TLSv1.2 TLSv1.3;41 location = /ws {1 proxy_pass http://127.0.0.1:3000;1 proxy_http_version 1.1;1 proxy_set_header Host $host;1 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;1 proxy_set_header X-Forwarded-Proto $scheme;1 proxy_set_header Upgrade $http_upgrade;1 proxy_set_header Connection $connection_upgrade;51 # Must exceed server heartbeatIntervalMs (30s) + heartbeatTimeoutMs (5s)1 proxy_read_timeout 75s;1 proxy_send_timeout 75s;1 proxy_buffering off;1 }61 location = /health {2 proxy_pass http://127.0.0.1:3000;2 }3}
1realtime.example.com {1 @websocket path /ws1 reverse_proxy @websocket 127.0.0.1:3000 {1 transport http {1 read_timeout 75s1 write_timeout 75s1 }1 }11 @health path /health1 reverse_proxy @health 127.0.0.1:30001}
1. Forward HTTPS port 443 with ACM certificate to HTTP target group on port 3000.
2. Set target group health check path to /health, status 200.
3. Set ALB idle timeout attribute to at least 75 seconds.