Log-follow streams (`/containers/{id}/logs?follow=1`) are cut every 10 minutes by `timeout server 10m`
Summary
GET /containers/{id}/logs?follow=1 is routed to dockerbackend, which inherits timeout server 10m from defaults. Any container that writes nothing for 10 minutes has its log stream closed by HAProxy (sD--). Log collectors then reconnect, and depending on the client this causes errors, missed lines, or re-delivery of old logs.
This is the same long-lived-stream problem that #98 fixed for /events (backend docker-events with timeout server 0), but log-follow requests weren't included.
Environment
tecnativa/docker-socket-proxy:latest(HAProxy 3.4.7-8872a26, 2026/10/14)- Docker Engine on Ubuntu, socket mounted
:ro CONTAINERS=1,EVENTS=1,POST=0- Client: Vector
docker_logssource (docker_host: http://logs-docker-proxy:2375)
Steps to reproduce
- Run the proxy with
CONTAINERS=1. - Follow the logs of a container that is quiet for more than 10 minutes, e.g.
curl -N "http://proxy:2375/containers/<id>/logs?follow=1&stdout=1&stderr=1" - The stream closes after about 600 s, and HAProxy logs:
dockerfrontend dockerbackend/dockersocket 0/0/0/0/600009 200 3449 - - sD-- ... "GET /containers/<id>/logs?... HTTP/1.1"
Impact (measured)
- 191
sD--closures on/logsin 6 hours on one host, one per quiet container every ~10 minutes. Busy containers never hit it. - With Vector, each cut is treated as a transient error and the stream is reopened with
since=<collector start time>(vectordotdev/vector#26023), so every cut re-sends the container's entire history. We saw up to 33× duplication in our log store, and one container re-transferred 11.6 MB in 3 hours. - Other clients are affected differently: CrowdSec (crowdsecurity/crowdsec#1469), LoggiFly (comment on #148), Traefik-style EOF errors (#21), and likely #89.
Proposed fix
Treat log-follow like events, in haproxy.cfg.template:
use_backend docker-events if { path,url_dec -m reg -i ^(/v[\d\.]+)?/events }
+ use_backend docker-logs if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/[^/]+/logs }
+
+backend docker-logs
+ server dockersocket $SOCKET_PATH
+ timeout server 0
Permission checks are unaffected, because the http-request deny rules run before backend selection.
With an infinite server timeout, a graceful stop can wait for streams that never end. #181 already reports this for /events, and adding log streams makes it more likely. A bounded default in global would cover both:
global
+ hard-stop-after 5s
An alternative is configurable timeouts via env vars (#148, which appears to have been closed by accident; addresses #89). Even then, a sensible default for log streams would avoid the problem for everyone.
Verification
I applied the change above locally by patching the template at container start, before docker-entrypoint.sh. After that:
- Zero
sD--closures on/logs. Containers idle for 15+ minutes kept their streams open, and the frontend'stimeout client 10mdid not interfere. - Duplication in the log store dropped to 1×.
- HAProxy only logs the expected "missing timeouts" warning, the same as for
docker-events.
Related: #98, #148, #89, #181, #21, vectordotdev/vector#26023.