http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } # ... } server { listen 80; server_name domain.com; location /ws/ { proxy_pass http://localhost:8060; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } If you connect to port 8060, the socket server is working. And through nginx I can not configure proxying
Connect
var socket = new WebSocket("ws://domain.com/ws"); Mistake
WebSocket connection to 'ws://domain.com/ws' failed: Error during WebSocket handshake: Unexpected response code: 301 If you add the last slash
var socket = new WebSocket("ws://domain.com/ws/"); WebSocket connection to 'ws://domain.com/ws/' failed: Error during WebSocket handshake: Unexpected response code: 404
/ws/? Something tells me that he can only handle/, and you try to/ws/open, to which he naturally answers 404 - andreymal/ws/passed on to the socket server on port 8060, but it does not know how to handle/ws/and gives an error 404. Most likely. - andreymal