Skip to content

Make nginx tuning configurable and pass streams through unbuffered - #43

Merged
mjmccans merged 4 commits into
mjmccans:mainfrom
javier-godoy:feat/nginx-tuning
Oct 27, 2026
Merged

mjmccans merged 4 commits into
mjmccans:mainfrom
javier-godoy:feat/nginx-tuning

Conversation

@javier-godoy

Copy link
Copy Markdown
Contributor

Clients that hold Docker API streams open, like events, followed logs, wait and exec/attach, don't work well behind the proxy as it stands:

  • Buffering delays streamed responses. nginx buffers proxied requests and responses by default, so output from events, logs, image pulls, builds and exports can reach the client late.
  • Large uploads are rejected. The default client_max_body_size of 1 MB makes uploads like build contexts and docker load fail with 413.
  • Idle streams are cut off. proxy_read_timeout closes any upstream connection that is quiet for 60 seconds, which ends idle events subscriptions and followed logs.
  • The connection limit is fixed. The generated config hard-codes worker_connections 1024. Since it runs a single worker, that is the limit for the whole proxy. Once long-lived streams from many clients fill it, nginx refuses new requests with worker_connections are not enough, and there's currently no way to raise the limit.

This PR:

  • Turns off request/response buffering and the body size limit, so streams pass straight through and uploads of any size are accepted.
  • Adds WORKER_CONNECTIONS to set worker_connections. It still defaults to 1024.
  • Adds PROXY_READ_TIMEOUT to set proxy_read_timeout, for example 24h for long-lived idle streams.
  • Adds TCP_KEEPALIVE to set so_keepalive on the listening port, so the connections of clients that have disappeared are detected and closed. This is useful together with a long PROXY_READ_TIMEOUT.

The new settings are only written to the config when set, so nginx's defaults stay in place otherwise. All of them are documented in a new "nginx Settings" section of the README.

Each commit is self-contained, so I'm happy to split this into separate PRs if you prefer.

@mjmccans
mjmccans merged commit 7fd88ae into mjmccans:main Oct 27, 2026
1 check passed
@javier-godoy
javier-godoy deleted the feat/nginx-tuning branch October 27, 2026 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants