# Single public entrypoint. Backends are discovered through Docker DNS (service name "api"), # so `docker compose up --scale api=N` needs no config change (up to 8 replicas). global log stdout format raw local0 info maxconn 4096 resolvers docker nameserver dns 127.0.0.11:53 resolve_retries 2 timeout resolve 1s timeout retry 500ms hold valid 1s hold other 1s hold refused 1s hold nx 1s hold timeout 1s hold obsolete 1s defaults mode http log global option httplog option dontlog-normal # log only errors and server state changes timeout connect 1s timeout client 30s timeout server 10s timeout http-request 10s timeout http-keep-alive 10s timeout check 1s # A request that never reached a backend (connect refused/timeout) is retried, the last time on # another server. Requests already sent are NOT retried: POST /users and /chats are not idempotent. retries 2 retry-on conn-failure option redispatch 1 frontend public bind :8080 default_backend api backend api balance roundrobin option httpchk http-check send meth GET uri /health/ready http-check expect status 200 # Active check every 1 s (0.5 s while state is changing): 2 failures -> DOWN, 2 successes -> UP. # A refused connection on live traffic marks the server DOWN immediately (observe layer4). default-server check inter 1s fastinter 500ms downinter 1s fall 2 rise 2 observe layer4 error-limit 1 on-error mark-down resolvers docker init-addr none server-template api 8 api:8080 # Operator view (bound to 127.0.0.1 on the host by compose): /stats and Prometheus /metrics. frontend stats bind :8404 http-request use-service prometheus-exporter if { path /metrics } stats enable stats uri /stats stats refresh 2s