2025-02-19 07:53:26 -08:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
# Global settings
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
global
|
|
|
|
|
# to have these messages end up in /var/log/haproxy.log you will
|
|
|
|
|
# need to:
|
|
|
|
|
#
|
|
|
|
|
# 1) configure syslog to accept network log events. This is done
|
|
|
|
|
# by adding the '-r' option to the SYSLOGD_OPTIONS in
|
|
|
|
|
# /etc/sysconfig/syslog
|
|
|
|
|
#
|
|
|
|
|
# 2) configure local2 events to go to the /var/log/haproxy.log
|
|
|
|
|
# file. A line like the following can be added to
|
|
|
|
|
# /etc/sysconfig/syslog
|
|
|
|
|
#
|
|
|
|
|
# local2.* /var/log/haproxy.log
|
|
|
|
|
#
|
|
|
|
|
log 127.0.0.1 local2
|
|
|
|
|
|
|
|
|
|
chroot /var/lib/haproxy
|
2026-04-01 22:27:07 -07:00
|
|
|
|
|
|
|
|
# DNS resolver for Docker container name resolution
|
|
|
|
|
# Re-resolves backend server addresses so container IP changes
|
|
|
|
|
# (from restarts, recreations, scaling) are picked up automatically
|
|
|
|
|
resolvers docker_dns
|
|
|
|
|
nameserver dns1 127.0.0.11:53
|
|
|
|
|
resolve_retries 3
|
|
|
|
|
timeout resolve 1s
|
|
|
|
|
timeout retry 1s
|
|
|
|
|
hold valid 10s
|
|
|
|
|
hold other 10s
|
|
|
|
|
hold refused 10s
|
|
|
|
|
hold nx 10s
|
|
|
|
|
hold timeout 10s
|
|
|
|
|
hold obsolete 10s
|
2025-02-19 07:53:26 -08:00
|
|
|
pidfile /var/run/haproxy.pid
|
|
|
|
|
maxconn 4000
|
|
|
|
|
user haproxy
|
|
|
|
|
group haproxy
|
|
|
|
|
daemon
|
|
|
|
|
|
2025-11-03 15:35:25 -08:00
|
|
|
# SSL and Performance
|
2025-02-19 07:53:26 -08:00
|
|
|
tune.ssl.default-dh-param 2048
|
2025-09-22 17:51:44 -07:00
|
|
|
|
Add rate limiting, connection limits, and timeout hardening
Activate HAProxy's built-in attack prevention to stop floods that cause
the container to become unresponsive:
- Stick table tracks per-IP: conn_cur, conn_rate, http_req_rate, http_err_rate
- Rate limit rules: deny at 50 req/s, tarpit at 20 req/s, connection
rate limit at 60/10s, concurrent connection cap at 100, error rate
tarpit at 20 errors/30s
- Harden timeouts: http-request 300s→30s, connect 120s→10s, client
10m→5m, keep-alive 120s→30s
- HTTP/2 Rapid Reset protection (CVE-2023-44487): stream and glitch limits
- Stats frontend on localhost:8404 for monitoring
- HEALTHCHECK now validates both port 80 (HAProxy) and 8000 (API)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 10:00:53 -07:00
|
|
|
# HTTP/2 protection against Rapid Reset (CVE-2023-44487) and stream abuse
|
|
|
|
|
tune.h2.fe.max-total-streams 2000
|
|
|
|
|
tune.h2.fe.glitches-threshold 50
|
|
|
|
|
|
2025-09-22 17:51:44 -07:00
|
|
|
# Stats persistence for zero-downtime reloads
|
|
|
|
|
stats-file /var/lib/haproxy/stats.dat
|
2025-02-19 07:53:26 -08:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
# common defaults that all the 'listen' and 'backend' sections will
|
|
|
|
|
# use if not designated in their block
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
|
defaults
|
|
|
|
|
mode http
|
|
|
|
|
log global
|
|
|
|
|
option httplog
|
|
|
|
|
option dontlognull
|
|
|
|
|
option http-server-close
|
|
|
|
|
option forwardfor #except 127.0.0.0/8
|
|
|
|
|
option redispatch
|
|
|
|
|
retries 3
|
Add rate limiting, connection limits, and timeout hardening
Activate HAProxy's built-in attack prevention to stop floods that cause
the container to become unresponsive:
- Stick table tracks per-IP: conn_cur, conn_rate, http_req_rate, http_err_rate
- Rate limit rules: deny at 50 req/s, tarpit at 20 req/s, connection
rate limit at 60/10s, concurrent connection cap at 100, error rate
tarpit at 20 errors/30s
- Harden timeouts: http-request 300s→30s, connect 120s→10s, client
10m→5m, keep-alive 120s→30s
- HTTP/2 Rapid Reset protection (CVE-2023-44487): stream and glitch limits
- Stats frontend on localhost:8404 for monitoring
- HEALTHCHECK now validates both port 80 (HAProxy) and 8000 (API)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 10:00:53 -07:00
|
|
|
timeout http-request 30s
|
2025-02-19 07:53:26 -08:00
|
|
|
timeout queue 2m
|
Add rate limiting, connection limits, and timeout hardening
Activate HAProxy's built-in attack prevention to stop floods that cause
the container to become unresponsive:
- Stick table tracks per-IP: conn_cur, conn_rate, http_req_rate, http_err_rate
- Rate limit rules: deny at 50 req/s, tarpit at 20 req/s, connection
rate limit at 60/10s, concurrent connection cap at 100, error rate
tarpit at 20 errors/30s
- Harden timeouts: http-request 300s→30s, connect 120s→10s, client
10m→5m, keep-alive 120s→30s
- HTTP/2 Rapid Reset protection (CVE-2023-44487): stream and glitch limits
- Stats frontend on localhost:8404 for monitoring
- HEALTHCHECK now validates both port 80 (HAProxy) and 8000 (API)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 10:00:53 -07:00
|
|
|
timeout connect 10s
|
|
|
|
|
timeout client 5m
|
2025-02-19 07:53:26 -08:00
|
|
|
timeout server 10m
|
Add rate limiting, connection limits, and timeout hardening
Activate HAProxy's built-in attack prevention to stop floods that cause
the container to become unresponsive:
- Stick table tracks per-IP: conn_cur, conn_rate, http_req_rate, http_err_rate
- Rate limit rules: deny at 50 req/s, tarpit at 20 req/s, connection
rate limit at 60/10s, concurrent connection cap at 100, error rate
tarpit at 20 errors/30s
- Harden timeouts: http-request 300s→30s, connect 120s→10s, client
10m→5m, keep-alive 120s→30s
- HTTP/2 Rapid Reset protection (CVE-2023-44487): stream and glitch limits
- Stats frontend on localhost:8404 for monitoring
- HEALTHCHECK now validates both port 80 (HAProxy) and 8000 (API)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 10:00:53 -07:00
|
|
|
timeout http-keep-alive 30s
|
2025-02-19 07:53:26 -08:00
|
|
|
timeout check 10s
|
2025-08-25 06:42:09 -07:00
|
|
|
timeout tarpit 10s # Tarpit delay for low-level scanners (before silent-drop)
|
2025-02-21 06:28:51 -08:00
|
|
|
maxconn 3000
|
|
|
|
|
|