work2fork
By:
work2fork

Nginx domain + socket.io problem

November 13, 2014 1.1k views

Hello! I've got an issue with my droplet. Maybe nginx config is bad, but I have no idea what goes wrong. When I have started node.js on 7000 port (I tried 3000, 3001 and others) and went from my browser (or any other browser from several machines) to droplet IP:port everything works correct. Socket.io works, navigation, sessionStore, authentication and other.
Problem begun when I start nginx server. It listens node.js' port and makes a connection to my domain. If I try to connect mydomain.com from browser it works everywhere except Google Chrome. I tried to catch this error and a problem is: Chrome tried to connect server with 'user-agent': 'WebIndex' with no handshakeData in request.headers.cookie. It breaks down connection in this browser, but in others my site works correctly.

This is strange because everything works good when I connect to droplet_IP:7000 instead of mydomain.com. There is no solution in google or stackoverflow and I have no idea what should I do. There is my stackoverflow question: http://stackoverflow.com/questions/26897525/socket-io-trouble-in-nginx

Is problem depends from bad domain name, proxy server or bad DNS? Thanks for help.

1 Answer

does it work now?
is it possible that socket.io doesnt work on digitalocean?
have similar problem:
https://www.digitalocean.com/community/questions/socket-io-node-js-with-dokku

Have another answer? Share your knowledge.