我正在尝试使用HAProxy来加载socket.io请求。以下是我的配置:
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend all 0.0.0.0:8888
mode http
timeout client 120s
option forwardfor
# Fake connection:close, required in this setup.
option http-server-close
option http-pretend-keepalive
acl is_socketio path_beg /socket.io
use_backend socket-servers if is_socketio
default_backend http-servers
backend http-servers
balance roundrobin
option httpclose
option forwardfor
# Roundrobin switching
server node-1 172.14.2.25:8887 check
server node-2 172.14.2.28:8887 check
backend socket-servers
mode http
timeout server 120s
balance roundrobin
# based on cookie set in header
# haproxy will add the cookies for us
option forwardfor
cookie SERVERID insert indirect nocache
server node1 172.14.2.25:8887 cookie node1 weight 1 maxconn 1024 check
server node2 172.14.2.28:8887 cookie node2 weight 1 maxconn 1024 check
当我尝试创建套接字连接时,此配置会超时。
但是,如果我删除最后两行[服务器node1 172.14.2.25:8887 cookie node1 weight 1 maxconn 1024 check 或服务器node2 172.14.2.28:8887 cookie node2重量1 maxconn 1024 check ],插座连接正确。
我不明白配置有什么问题。任何帮助将受到高度赞赏。
TIA:)
答案 0 :(得分:1)
在后端套接字服务器的配置中,我不得不将余额roundrobin更改为余额源。那很有效! :)