global maxconn 4096 pidfile ~/tmp/haproxy-queue.pid defaults log global log 127.0.0.1 local0 log 127.0.0.1 local1 notice mode tcp option httplog option http-server-close #option dontlognull option redispatch option contstats retries 3 backlog 10000 timeout client 25s timeout connect 5s timeout server 25s # timeout tunnel available in ALOHA 5.5 or HAProxy 1.5-dev10 and higher timeout tunnel 3600s timeout http-keep-alive 1s timeout http-request 15s timeout queue 30s timeout tarpit 60s default-server inter 3s rise 2 fall 3 option forwardfor frontend gateways bind *:6767 default_backend bk_ws backend bk_ws balance leastconn ## websocket protocol validation # acl hdr_connection_upgrade hdr(Connection) -i upgrade # acl hdr_upgrade_websocket hdr(Upgrade) -i websocket # acl hdr_websocket_key hdr_cnt(Sec-WebSocket-Key) eq 1 # acl hdr_websocket_version hdr_cnt(Sec-WebSocket-Version) eq 1 # acl hdr_host hdr_cnt(Sec-WebSocket-Version) eq 1 # http-request deny if ! hdr_connection_upgrade ! hdr_upgrade_websocket ! hdr_w #ebsocket_key ! hdr_websocket_version ! hdr_host ## ensure our application protocol name is valid ## (don't forget to update the list each time you publish new applications) acl ws_valid_protocol hdr(Sec-WebSocket-Protocol) echo-protocol http-request deny if ! ws_valid_protocol ## websocket health checking #option httpchk GET / HTTP/1.1\r\nHost:\ ws.domain.com\r\nConnection:\ Upgrade #\r\nUpgrade:\ websocket\r\nSec-WebSocket-Key:\ haproxy\r\nSec-WebSocket-Version # :\ 13\r\nSec-WebSocket-Protocol:\ echo-protocol # http-check expect status 101 server websrv1 127.0.0.1:6769 maxconn 1000 weight 10 cookie gateway1 check server websrv2 127.0.0.1:6771 maxconn 1000 weight 10 cookie gateway2 check