Files
mtusi2026lab7/infra/haproxy.cfg
T
2026-11-25 18:52:25 +03:00

42 lines
2.0 KiB
INI

global
maxconn 256
nbthread 1
ssl-default-bind-options ssl-min-ver TLSv1.2
ssl-default-server-options ssl-min-ver TLSv1.2
defaults
mode http
timeout connect 3s
timeout client 90s
timeout server 90s
timeout check 3s
resolvers docker
nameserver dns 127.0.0.11:53
hold valid 2s
hold obsolete 1s
hold nx 1s
frontend ingress
bind :8443 ssl crt /identity/bundle.pem
stick-table type ip size 32k expire 1m store http_req_rate(15s)
acl login_path path -i /api/v1/auth/sessions
http-request set-var(txn.rid) uuid()
http-request track-sc0 src if METH_POST login_path
http-request return status 429 content-type application/json lf-string '{"error":{"code":"rate_limited","message":"Login limit","request_id":"%[var(txn.rid)]"}}' hdr X-Request-Id %[var(txn.rid)] hdr X-Instance-Id ingress hdr Retry-After 15 if METH_POST login_path { sc_http_req_rate(0) gt 15 }
http-request return status 413 content-type application/json lf-string '{"error":{"code":"payload_too_large","message":"Body exceeds limit","request_id":"%[var(txn.rid)]"}}' hdr X-Request-Id %[var(txn.rid)] hdr X-Instance-Id ingress if { req.hdr_val(content-length) gt 10485760 }
# The upload handler counts decoded body bytes for streaming uploads.
acl upload_path path_reg ^/api/v1/chats/[^/]+/attachments$
http-request return status 411 if { req.hdr(transfer-encoding) -m found } !upload_path
http-request deny deny_status 404 if { path_beg /actuator }
http-request del-header X-User-Id
http-request set-header X-Forwarded-For %[src]
default_backend replicas
backend replicas
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host api
http-check expect status 200
server-template node 1-8 api:8443 ssl verify required ca-file /identity/ca.crt crt /identity/bundle.pem verifyhost api sni str(api) check-sni api check inter 2s fall 2 rise 1 resolvers docker resolve-prefer ipv4 init-addr none