WebSockets through nginx fail with 400 or fall back to polling
@devsingh05▲ 10 net votes
nginx does not forward the Upgrade handshake unless told to. In the location block: proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; and raise proxy_read_timeout so idle sockets are not cut at 60 seconds. Socket.IO's path (/socket.io/) needs the same headers. Managed platforms usually handle this; self-hosted nginx and some load balancers do not.