Skip to content

feat(nginx): add NGINX_WORKER_PROCESSES env var - #456

Merged
theseion merged 2 commits into
coreruleset:mainfrom
fzipi:add-nginx-worker-processes-var
Aug 5, 2026
Merged

feat(nginx): add NGINX_WORKER_PROCESSES env var#456
theseion merged 2 commits into
coreruleset:mainfrom
fzipi:add-nginx-worker-processes-var

Conversation

@fzipi

@fzipi fzipi commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds an NGINX_WORKER_PROCESSES environment variable to control nginx's worker_processes directive (previously hardcoded to auto)
  • Default stays auto, so behavior is unchanged unless the variable is set explicitly

Why

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).

Reapplies the change reverted in #455, this time through normal PR review.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for configuring the number of NGINX worker processes through the NGINX_WORKER_PROCESSES environment variable.
    • The setting defaults to auto, while allowing a fixed value when needed.
    • Configuration is applied consistently across standard and Alpine-based images.
  • Documentation

    • Documented the new environment variable, including its default and configuration example.

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.
@fzipi
fzipi requested a review from Copilot August 3, 2026 20:38
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42d00b88-10a1-48ee-94a0-8bb6d976a3db

📥 Commits

Reviewing files that changed from the base of the PR and between d057864 and 605ad5b.

📒 Files selected for processing (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

📝 Walkthrough

Walkthrough

The Docker images now define NGINX_WORKER_PROCESSES=auto. The NGINX template uses this variable for the worker_processes directive. The README documents the variable and its effect on log writes.

Changes

NGINX worker process configuration

Layer / File(s) Summary
Worker process configuration
nginx/Dockerfile, nginx/Dockerfile-alpine, nginx/templates/nginx.conf.template, README.md
Both Dockerfiles set NGINX_WORKER_PROCESSES=auto. The NGINX template references the variable in the worker_processes directive. The README documents the variable and its fixed-value behavior.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

Suggested reviewers: theseion

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of the NGINX_WORKER_PROCESSES environment variable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c0ee516 and d057864.

📒 Files selected for processing (4)
  • README.md
  • nginx/Dockerfile
  • nginx/Dockerfile-alpine
  • nginx/templates/nginx.conf.template

Comment thread README.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PROCESSES to control the worker_processes directive (default remains auto).
  • 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.

theseion
theseion previously approved these changes Aug 4, 2026
@theseion
theseion enabled auto-merge (squash) August 4, 2026 05:00
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@theseion
theseion disabled auto-merge August 5, 2026 05:33
@theseion
theseion merged commit 85caf99 into coreruleset:main Aug 5, 2026
38 checks passed
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.

3 participants