First distinguish a failed connection handshake from a connection that opens and later closes. The two symptoms lead to different checks.
Let the application receive the upgrade request
For a dedicated WebSocket route, place this inside server:
location /socket/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
explicitly uses HTTP/1.1 toward the backend. passes the client's requested protocol change. tells the backend this connection is requesting that change. These headers need explicit forwarding because proxies do not simply pass every connection-specific header onward.
