NGINX를 여러 클러스터 프로세스의 요청을로드 밸런싱하는 Socket.IO 서버용 리버스 프록시로 실행하고 있습니다. 각 클러스터 프로세스는 다른 포트에서 청취하도록 지시받습니다.Socket.IO nginx로드 밸런서 문제가있는 클러스터
의 nginx 서버는 IP 해시 기반으로로드 밸런싱을하도록 구성되어 있지만 메시지를 얻을 :
ws://{domain}/socket.io/?EIO=3&transport=websocket&sid=KaU3C8caGVK4gU1LAAAB failed: WebSocket is closed before the connection is established.
내의 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;
}
}
기본 가상 호스트 :
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 서버를 실행하면 올바르게 작동합니다.이 설정에 사용한 참조는 다음 위치에 있습니다. http://socket.io/docs/using-multiple-nodes/.
감사