Skip to content

Instantly share code, notes, and snippets.

@sjimenez44
Forked from Philmod/haproxy.cfg
Created September 20, 2021 16:02
Show Gist options
  • Save sjimenez44/1df8f1c44f56fc5640f7fea912f8015c to your computer and use it in GitHub Desktop.
Save sjimenez44/1df8f1c44f56fc5640f7fea912f8015c to your computer and use it in GitHub Desktop.
HAProxy configuration for the socket.io chat example, splitted into frontend and websocket servers.
global
log 127.0.0.1 local0
maxconn 8192
user haproxy
group haproxy
defaults
log global
mode http
option httplog
option http-server-close
option dontlognull
option redispatch
option contstats
retries 3
backlog 10000
timeout client 35s
timeout connect 5s
timeout server 35s
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
listen stats
bind *:8080
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /status
stats auth user:password
frontend public
bind *:80
maxconn 10000
acl is_websocket hdr_end(host) -i ws.node-example.com
use_backend ws if is_websocket
default_backend www
backend www
timeout check 5000
option httpchk GET /status?haproxy=1
balance roundrobin
server www1 10.142.0.3:3001 maxconn 1000 weight 10 cookie websrv_www check inter 10000 rise 1 fall 3
server www2 10.142.0.6:3001 maxconn 1000 weight 10 cookie websrv_www check inter 10000 rise 1 fall 3
backend ws
timeout check 5000
option httpchk GET /status?haproxy=1
balance roundrobin
cookie HAPROXY_COOKIE insert indirect nocache
server ws1 10.142.0.4:3002 maxconn 1000 weight 10 cookie websrv_ws check inter 10000 rise 1 fall 3 check cookie ws1
server ws2 10.142.0.7:3002 maxconn 1000 weight 10 cookie websrv_ws check inter 10000 rise 1 fall 3 check cookie ws2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment