nginx - WebSocket connection to 'ws://<ip>..failed: Error during WebSocket handshake: Unexpected response code: 502 -


i'm using node,socket.io,nginx socket connections http based simple application. below nginx.conf configured websockets, socket io present in socket/socket.io. strange thing same config works when run node application in localhost , nginx port 80. not sure why failing in linux real ip addresses.

http {   upstream io_nodes {     ip_hash;     server ip:port; --> application's ip , port     server ip:port;    }    include mime.types;   default_type application/octet-stream;   sendfile on;   keepalive_timeout 1000;    # http server   server {     listen 80;     server_name ip;     server_tokens off;     #proxy_ssl_verify off;      # prevents 502 bad gateway error     large_client_header_buffers 8 32k;      location /dummy/ {       root html;       index dummy/index.html;     }      location /socket/socket.io {     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;        # prevents 502 bad gateway error         proxy_buffers 8 32k;         proxy_buffer_size 64k;        proxy_pass http://io_nodes/;       proxy_redirect off;        proxy_http_version 1.1;       proxy_set_header upgrade $http_upgrade;       proxy_set_header connection "upgrade";             proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;       proxy_set_header host $host;     }      #location /socket.io/ {     #  proxy_pass http://io_nodes/socket.io/;     #}      location /assistlog/socket.io {     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;      # prevents 502 bad gateway error         proxy_buffers 8 32k;         proxy_buffer_size 64k;        proxy_pass http://10.73.52.187:4444/;       proxy_redirect off;        proxy_http_version 1.1;       proxy_set_header upgrade $http_upgrade;       proxy_set_header connection "upgrade";        proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;       proxy_set_header host $host;      } } } 

and console error in chrome

websocket connection 'ws://ip/socket/socket.io/?pathname=%2fdemoui%2findex.html&eio=3&transport=websocket' failed: error during websocket handshake: unexpected response code: 502 

please suggest solution.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -