Node.js Socket.IO群集存在nginx负载平衡器问题

Node.js Socket.IO群集存在nginx负载平衡器问题,node.js,nginx,socket.io,Node.js,Nginx,Socket.io,我将NGINX作为Socket.IO服务器的反向代理运行,该服务器负责跨多个集群进程平衡请求。每个集群进程都被告知在不同的端口上侦听 nginx服务器已配置为基于IP哈希的负载平衡,但我收到消息: ws://{domain}/socket.io/?EIO=3&transport=websocket&sid=kau3c8cagvk4gu1laab失败:在建立连接之前websocket已关闭。 我的nginx配置有: http { {+ default configs} upstr

我将NGINX作为Socket.IO服务器的反向代理运行,该服务器负责跨多个集群进程平衡请求。每个集群进程都被告知在不同的端口上侦听

nginx服务器已配置为基于IP哈希的负载平衡,但我收到消息:

ws://{domain}/socket.io/?EIO=3&transport=websocket&sid=kau3c8cagvk4gu1laab失败:在建立连接之前websocket已关闭。

我的nginx配置有:

http {
    {+ default configs}

    upstream io_nodes {
        ip_hash;
        server 127.0.0.1:3000;
        server 127.0.0.1:3001;
        server 127.0.0.1:3002;
        server 127.0.0.1:3003;
    }

}
默认vhost:

server {
#listen   80; ## listen for ipv4; this line is default and implied
#listen   [::]:80 default ipv6only=on; ## listen for ipv6

root /usr/share/nginx/www/static/web;
index index.html index.htm;

# Make site accessible from http://localhost/
server_name {domain};

location / {
        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;
        proxy_http_version 1.1;
        proxy_pass http://io_nodes;
     }
}
任何帮助都将不胜感激。如果我在没有群集的情况下运行nodejs服务器,则它的行为正常,我用于此设置的引用位于:


谢谢

我发现问题在于安装的nginx版本<1.3并且没有websockets支持

对于其他人,您可以从以下网址查看如何在ubuntu上安装较新版本的nginx: