Files
mtusi2026lab7/infra/haproxy/haproxy.cfg
T

56 lines
2.2 KiB
INI

# HAProxy — единственная публичная точка входа. Lab7:
# клиент → LB: TLS 1.2+ на :8443 (сертификат CN/SAN localhost, 127.0.0.1, CA стенда);
# LB → API: mTLS — LB проверяет сервер (CA + имя api) и предъявляет свой клиентский
# сертификат identity spiffe://messenger/lb (API пускает только её). Plaintext нет.
# Backend-адреса — из встроенного DNS Docker (service name "api").
global
log stdout format raw local0 info
maxconn 2048
ssl-default-bind-options ssl-min-ver TLSv1.2
ssl-default-server-options ssl-min-ver TLSv1.2
defaults
mode http
log global
option httplog
option dontlognull
timeout connect 2s
timeout client 30s
timeout server 15s
timeout http-request 10s
timeout queue 5s
retries 2
retry-on conn-failure
option redispatch 1
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 5s
hold other 5s
hold refused 5s
hold nx 2s
hold timeout 5s
hold obsolete 2s
accepted_payload_size 8192
frontend public
bind :8443 ssl crt /run/secrets/lb-public.pem alpn http/1.1
# Тело больше 11 MiB отклоняется на входе (вложение ≤ 10 MiB, JSON ≤ 64 KiB — в API).
http-request deny deny_status 413 if { req.hdr_val(content-length) gt 11534336 }
# IP клиента — только из соединения; присланный клиентом X-Forwarded-For заменяется.
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Proto https
default_backend api
backend api
balance "${LB_BALANCE}"
option httpchk
http-check send meth GET uri /health/ready
http-check expect status 200
default-server check inter 1s fastinter 500ms downinter 1s fall 2 rise 2 resolvers docker resolve-prefer ipv4 init-addr none ssl verify required ca-file /run/secrets/ca.crt crt /run/secrets/lb.pem verifyhost api sni str(api)
server-template api 8 api:8443