011websocket代理
一、安装haproxy
sudo add-apt-repository ppa:vbernat/haproxy-2.6 -y
sudo apt install haproxy -y
sudo systemctl status haproxy
sudo systemctl enable haproxy
cd /etc/haproxy
cp haproxy.cfg{,.20221229_140724}
vim haproxy.cfg && sudo systemctl restart haproxy
二、haproxy配置
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers xxx
ssl-default-bind-ciphersuites xx
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
defaults
log global
mode http
option httplog
option dontlognull
#timeout connect 5000
#timeout client 50000
#timeout server 50000
timeout tunnel 24h
timeout client-fin 30s
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend front_websocket
bind *:23651
mode http
## routing based on websocket protocol header
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
use_backend back_websocket if hdr_connection_upgrade hdr_upgrade_websocket
backend back_websocket
balance roundrobin
cookie SERVERID
server host1 x.x.5.8:23651 cookie host1 maxconn 50000 check inter 10s rise 3 fall 3s
三、测试
http://www.easyswoole.com/wstool.html

reference: https://segmentfault.com/a/1190000042773675

浙公网安备 33010602011771号