node.js - socket io with node js is not connecting through nginx proxy_pass -
the issue when use nginx socket not establishing.any 1 me in steps follow integrate socket oi nginx. tried this
location /field { # following required websockets proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-nginx-proxy true; # supposedly prevents 502 bad gateway error; # not necessary in case proxy_buffers 8 32k; proxy_buffer_size 64k; # following required proxy_pass proxy_redirect off; # following required websockets proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; tcp_nodelay on; # not necessary }
first of check nginx version. according page websockets supported after v1.3.13;
http://nginx.com/blog/nginx-nodejs-websockets-socketio/
then compare nginx conf below configuration stated in nginx blog;
map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream websocket { server 192.168.100.10:8010; } server { listen 8020; location / { proxy_pass http://websocket; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection $connection_upgrade; } }
http://nginx.com/blog/websocket-nginx/
also check firewall configuration port chose socket.io server. (i've read isps blocking websocket connection ports other 80 & 443, please check if server receive packets using tcpdump etc.)
if everyhing okay until now, check nginx error logs (/var/log/nginx/error.log) see if there socket.io related error messages. can paste here further analysis.
then if there no socket error in nginx logs start node app debug mode on below;
debug=* node yourfile.js
and check if socket connection message printed console. can paste further analysis.
Comments
Post a Comment