I’m trying to configure Nginx to work with Socket.IO
and I have found this in Socket.IO github wiki.
I have installed Nginx 1.1.10.
server {
listen 80;
server_name socket.myserver.com;
location / {
proxy_pass http://localhost:3030;
}
}
Below is my Socket.io code
var io = require('socket.io').listen(3030);
io.configure(function() {
io.enable('browser client etag');
io.set('transports', [
'websocket','xhr-polling'
]);
});
io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
And this is my client site code
<html>
<head>
<script src="http://socket.mysite.com/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://socket.mysite.com');
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
</script>
</head>
<body></body>
</html>
I’m confronting problem that the console shows only
info - socket.io started
debug - served static content /socket.io.js
I know that it should creates some logs about “handshakes and heartbeats”
Did I configure something wrong? Or does my code have some errors?
According to your config, node is listening on port 3333, but nginx is trying to proxy_pass to port 3030. Those need to match.