Files
polylan-submitter/deploy/haproxy/haproxy.cfg
T
2026-09-17 17:28:06 +02:00

48 lines
2.1 KiB
INI

# HAProxy config for polylan-submitter. Plain HTTP only - TLS is terminated
# upstream of this box, so nothing here handles certs or :443.
#
# Unlike nginx/Caddy's per-site snippet directories, HAProxy's default
# packaging expects one single /etc/haproxy/haproxy.cfg for the whole
# process, so this file IS the full config - deploy.sh copies it wholesale
# rather than dropping a fragment into an "enabled" dir. If this box also
# runs other things through HAProxy, fold this frontend/backend into your
# existing haproxy.cfg by hand instead of letting deploy.sh clobber it.
#
# This is no longer a template: it's a plain, ready-to-use config with one
# statically defined backend server (web-00, the first daphne socket), so
# the backend is never empty right after a reload - traffic has somewhere to
# go immediately. deploy.sh adds the remaining NUM_WEB_WORKERS-1 servers over
# the admin socket below (`add server` + `enable server`) every time it
# reloads HAProxy, since a reload always resets the running process back to
# exactly what's in this file. Deploy sequence is always: cp this file ->
# reload -> re-add the rest of the servers.
#
# WebSocket (submissions/clock/place) needs no special handling here: modern
# HAProxy in `mode http` detects the 101 Switching Protocols response and then
# just relays bytes both ways for the rest of that connection - that only
# works because keep-alive is the default connection mode below (no
# `option http-server-close` / `httpclose`, either of which would break it).
# Static files are served in-process by WhiteNoise (see MIDDLEWARE in
# settings.py), so nothing else needs to be carved out here either.
global
log /dev/log local0
maxconn 2000
stats socket /run/haproxy/admin.sock mode 660 level admin
defaults
mode http
log global
option httplog
timeout connect 5s
timeout client 60s
timeout server 60s
frontend polylan_submitter_http
bind *:7777
default_backend polylan_submitter_web
backend polylan_submitter_web
balance roundrobin
server web-00 unix@/opt/polylan-submitter/run/web-00.sock check