feat(nginx): add NGINX_WORKER_PROCESSES env var - #456
Conversation
worker_processes was hardcoded to auto, which spreads nginx's buffered log writes across multiple worker processes. When several workers race to flush, log lines can land out of order, which breaks consumers that rely on log markers to bound a single request's output (e.g. go-ftw's marker-based test runner, coreruleset/go-ftw#473). Default stays auto, so behavior is unchanged unless the variable is set explicitly, e.g. to 1 to serialize log writes. This reapplies the change reverted in coreruleset#455, this time through PR review instead of a direct push to main.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Docker images now define ChangesNGINX worker process configuration
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 261: Update the NGINX_WORKER_PROCESSES documentation to state that
setting it to exactly 1 serializes log writes; remove the implication that any
fixed number provides this behavior, while retaining the default value and
directive reference.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4149b45d-fd45-4676-a175-934ce16dfa1f
📒 Files selected for processing (4)
README.mdnginx/Dockerfilenginx/Dockerfile-alpinenginx/templates/nginx.conf.template
There was a problem hiding this comment.
Pull request overview
This PR reintroduces configurability for nginx’s worker_processes by exposing it as an environment variable, enabling users (and test harnesses) to force single-worker operation to avoid out-of-order log lines.
Changes:
- Add
NGINX_WORKER_PROCESSESto control theworker_processesdirective (default remainsauto). - Update nginx config template to use the new environment-driven value.
- Document the new environment variable in the README and set defaults in both nginx Dockerfiles.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| README.md | Documents NGINX_WORKER_PROCESSES and its intended use for serializing log output. |
| nginx/templates/nginx.conf.template | Replaces hardcoded worker_processes auto; with ${NGINX_WORKER_PROCESSES}. |
| nginx/Dockerfile-alpine | Sets default NGINX_WORKER_PROCESSES=auto for the alpine nginx image variant. |
| nginx/Dockerfile | Sets default NGINX_WORKER_PROCESSES=auto for the debian-based nginx image variant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
NGINX_WORKER_PROCESSESenvironment variable to control nginx'sworker_processesdirective (previously hardcoded toauto)auto, so behavior is unchanged unless the variable is set explicitlyWhy
worker_processeswas hardcoded toauto, which spreads nginx's buffered log writes across multiple worker processes. When several workers race to flush, log lines can land out of order, which breaks consumers that rely on log markers to bound a single request's output (e.g. go-ftw's marker-based test runner, coreruleset/go-ftw#473).Reapplies the change reverted in #455, this time through normal PR review.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
NGINX_WORKER_PROCESSESenvironment variable.auto, while allowing a fixed value when needed.Documentation