Skip to content

Improve: send nginx request errors to the container log - #24

Merged
SandObserver merged 1 commit into
mainfrom
improve/nginx-request-logging
Aug 10, 2026
Merged

SandObserver merged 1 commit into
mainfrom
improve/nginx-request-logging

Conversation

@SandObserver

Copy link
Copy Markdown
Owner

Summary

  • Add a server-level error_log stderr warn; to nginx/dashboard.conf, so request-time failures appear in docker logs.
  • Add a server-level access_log off;, replacing an unrotated file in the container's writable layer.
  • Leave the existing access_log off; on the /health location untouched.

Alpine's packaged nginx.conf sends both logs to files under /var/log/nginx. The container installs no logrotate and runs no cron, so nothing read those files and nothing trimmed them.

Both directives are valid in the server context, so this needs no change to /etc/nginx/nginx.conf. The scope limit is deliberate: master and startup errors still follow the main context, and docker-entrypoint.sh already refuses to start on a config nginx rejects.

Testing
All green, including the Docker build. Verified in a built container: a request over the body limit now writes client intended to send too large body to docker logs, an unreachable upstream writes connect() failed, and both files under /var/log/nginx stay at zero bytes. Added 3 tests pinning the two directives and the health-check exclusion.

Checklist

  • Stays within the project constraints: one container, no runtime dependencies, no build step (see CONTRIBUTING.md).
  • Tests added or updated for new logic, and the full suite, lint, and typechecks pass.
  • Docs updated if behavior or configuration changed. The documentation change lands separately, so it can describe what actually shipped.
  • CHANGELOG.md updated under Unreleased if the change is user-visible. The changelog entry lands with the documentation change.

Alpine's packaged nginx.conf writes the access and error logs to files under
/var/log/nginx. Nothing in the container reads them and nothing trims them:
no logrotate binary is installed and no cron runs. Request failures were
therefore invisible in `docker logs` while the files grew unbounded in the
writable layer.

Both directives are set in the server context, so this stays in a file the
repo owns. Master and startup errors still follow the main context, which
docker-entrypoint.sh already guards by refusing to start on a rejected config.
@SandObserver SandObserver added the docker Pull requests that update docker code label Aug 10, 2026
@SandObserver
SandObserver merged commit bf69430 into main Aug 10, 2026
4 checks passed
@SandObserver
SandObserver deleted the improve/nginx-request-logging branch August 10, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update docker code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant