Monday, 4 September 2017
how do you setup socket.io and nginx
I'm trying to get socket.io working on my production site which is secured through ssl. I'm using nginx to manage the ssl connection for the main express app and I'd also like to use it to proxy the socket.io connection.So far, I can get the server to respond to a connection from the client but I can't emit events from client to server or server to client.here's my /etc/nginx/sites-available/default:upstream io_nodes { ip_hash; server 127.0.0.1:8000; } server { listen 80 default_server; listen [::]:80 default_server; server_name ; return 301 https://$server_name$request_uri; } server { listen 443 ssl default_server; listen [::]:443 ssl default_server; include snippets/ssl-<host name>.conf; include snippets/ssl-params.conf; location ~ /.well-known { allow all; root /var/www/html; } location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /socket.io { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_http_version 1.1; proxy_pass http://localhost:8000; } } I'm also on version 1.6.2 of nginx so that might be part of the problem.Any insights here?Thanks!<br><br>
Submitted September 05, 2017 at 02:18AM by spinlock
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment