global log stdout format raw local0 maxconn 4096 # Docker's embedded DNS. Re-resolving the replica names periodically prevents a # stale address from being used if a container is recreated with another IP # (a name resolved once at startup can otherwise point to the wrong replica). resolvers docker nameserver dns1 127.0.0.11:53 resolve_retries 3 timeout resolve 1s timeout retry 1s hold valid 5s hold nx 1s hold timeout 1s hold refused 1s hold other 1s defaults mode http log global option httplog option dontlognull option redispatch # Close the server-side connection after each response so that roundrobin # distributes every request instead of reusing one idle backend connection. option http-server-close retries 2 # A stopped container's IP silently drops packets, so a short connect # timeout bounds how long a request waits before redispatch to a live peer. timeout connect 500ms timeout client 60s timeout server 60s frontend public_http bind *:8080 default_backend api_backend backend api_backend balance roundrobin option httpchk GET /health/ready http-check expect status 200 # Fast detection: a stopped replica must leave rotation within a couple of # seconds, otherwise in-flight writes fail while the LB still routes to it. default-server check inter 1s fastinter 200ms downinter 500ms fall 2 rise 1 server api1 api1:8080 check resolvers docker init-addr none server api2 api2:8080 check resolvers docker init-addr none