【发布时间】:2015-01-19 04:28:46
【问题描述】:
我刚刚在我的 Debian 系统上安装了 HaProxy 1.6,我想用它来分发 WebSocket (WS://) 连接。系统正在运行同一个 WebSocket 服务的 5 个服务器实例;这些实例具有相同的 IP 地址但不同的端口:
192.168.10.1:801
192.168.10.1:802
192.168.10.1:803
192.168.10.1:804
192.168.10.1:805
我正在寻找一些建议来创建一个简单的配置文件来监听端口 800 上的请求并在服务器之间平均分配(也许?)。
defaults
mode http
# Set timeouts to your needs
timeout client 5s
timeout connect 5s
timeout server 5s
frontend all 0.0.0.0:800
mode http
timeout client 120s
option forwardfor
# Fake connection:close, required in this setup.
option http-server-close
option http-pretend-keepalive
acl is_sockjs path_beg /echo /broadcast /close
acl is_stats path_beg /stats
use_backend sockjs if is_sockjs
use_backend stats if is_stats
default_backend static
backend sockjs
# Load-balance according to hash created from first two
# directories in url path. For example requests going to /1/
# should be handled by single server (assuming resource prefix is
# one-level deep, like "/echo").
balance uri depth 2
timeout server 120s
server srv_sockjs1 127.0.0.1:12345
# server srv_sockjs2 127.0.0.1:9998
backend static
balance roundrobin
server srv_static 127.0.0.1:801
backend stats
stats uri /stats
stats enable
我设法通过使用我下载的上述配置文件以某种方式使其工作。但对我来说它看起来太复杂了,一次只接受一个连接。如果第二个客户端连接,HA 代理断开前一个/第一个,并连接一个新/第二个 ..
【问题讨论】: