workerman分布式部署
1、NGINX + websocket负载均衡
http {
upstream websocket_cluster {
# Workerman 节点地址,可多台机器或多个端口
server 192.168.1.10:7272;
server 192.168.1.11:7272;
server 192.168.1.12:7272;
}
server {
listen 80;
server_name yourdomain.com;
location /ws/ {
proxy_pass http://websocket_cluster;
# WebSocket 必要头部
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 防止超时
proxy_read_timeout 60s;
proxy_send_timeout 60s;
}
}
}