I am trying to make running my app (using socket.io) under nginx, and i get an WebSocket connection to 'ws://...' failed: Unexpected response code: 502
error on the server side.
I have read that nginx suport the websockets since the v.1.3
so i just have upgrade to the nginx v1.4.1 (stable)
.
Here is my conf:
server {
listen 80;
server_name website.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
access_log /var/log/nginx/website/access.log;
error_log /var/log/nginx/website/error.log;
}
}
UPDATE:
I have to say that i can reach the app (so i do listen the port 3000) and socket.io is working unless this error, but in some cases, the emit
call desn't send any arguments so i get undefined
.
What am i missing here to avoid this error?