Skip to content

fix: handle multiple nginx-proxy replicas sharing a label - #1275

Open
JamBalaya56562 wants to merge 2 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/nginx-replicas-reload
Open

fix: handle multiple nginx-proxy replicas sharing a label#1275
JamBalaya56562 wants to merge 2 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/nginx-replicas-reload

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What

Handle the case where the nginx-proxy (or docker-gen) detection label matches more than one container. Closes #1006.

Why

labeled_cid returns one container ID per line, so when several nginx replicas share the same label, get_nginx_proxy_container returns multiple newline-separated IDs. Code that treated that as a single ID embedded it directly in the Docker API URL and broke: the health check reported ... isn't running, the reload reached no replica, and the startup check failed with can't get docker-gen container id for multiple all-in-one replicas.

How

  • check_nginx_proxy_container_run: read the IDs into an array; the proxy is considered up if any matched container is running.
  • reload_nginx: iterate over every docker-gen and nginx-proxy ID (SIGHUP, or docker exec for the all-in-one path).
  • entrypoint.sh startup check: new nginx_proxy_is_docker_gen helper iterates the IDs to detect a bundled docker-gen, instead of passing the whole string to is_docker_gen_container.

With a single matching container everything behaves as before (one iteration), so the docker_api / docker_api_legacy tests are unchanged.

Test

New nginx_replicas integration test covers both paths: (1) separate docker-gen + two labeled nginx replicas — both receive SIGHUP and the health check passes; (2) two all-in-one nginx-proxy replicas — the companion starts instead of failing the docker-gen check.

Verified locally

Two labeled replicas: get_nginx_proxy_container returns 2 IDs, the health check passes, reload_nginx sends SIGHUP to both, and the companion starts cleanly with two all-in-one replicas (the old single-arg check failed there).

Out of scope

docker_restart (LETSENCRYPT_<cid>_RESTART_CONTAINER) targets proxied app containers, not nginx replicas, so it is unaffected.

🤖 Generated with Claude Code

@JamBalaya56562
JamBalaya56562 force-pushed the fix/nginx-replicas-reload branch from cf6d5b0 to 8cdd8ac Compare June 20, 2026 13:34
@JamBalaya56562 JamBalaya56562 changed the title fix: reload and check all nginx-proxy replicas sharing a label fix: handle multiple nginx-proxy replicas sharing a label Jun 20, 2026
@buchdag
buchdag requested a review from Copilot June 28, 2026 11:51

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 fixes nginx-proxy/docker-gen detection and reload behavior when the detection label matches multiple containers (e.g., Swarm replicas), preventing newline-separated container IDs from breaking Docker API calls and startup checks (closes #1006).

Changes:

  • Update check_nginx_proxy_container_run to treat the proxy as “up” if any matched replica is running.
  • Update reload_nginx to iterate over all matched docker-gen and nginx-proxy container IDs (SIGHUP or all-in-one docker exec path).
  • Add an integration test (nginx_replicas) and wire it into the test suite and CI matrix.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/functions.sh Iterates over multiple matched container IDs for health checks, reloads, and bundled docker-gen detection.
app/entrypoint.sh Uses the new helper to detect bundled docker-gen across multiple nginx-proxy replicas.
test/tests/nginx_replicas/run.sh Adds an integration test covering separate docker-gen + multiple nginx replicas and multiple all-in-one replicas.
test/config.sh Registers the new nginx_replicas test in the global test list.
.github/workflows/test.yml Adds nginx_replicas to the GitHub Actions matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/functions.sh
@JamBalaya56562

Copy link
Copy Markdown
Contributor Author

Addressed the Copilot review (grammar fix: "an nginx-proxy container ID").

@buchdag

buchdag commented Jul 12, 2026

Copy link
Copy Markdown
Member

@JamBalaya56562 please flag AI-generated PR explicitly in the PR description (ie "🤖 Generated with Claude Code" like in this PR) and add the AI agent as co-author of the commits.

@JamBalaya56562
JamBalaya56562 force-pushed the fix/nginx-replicas-reload branch from 3c6573c to 136faef Compare July 12, 2026 22:42
@JamBalaya56562

Copy link
Copy Markdown
Contributor Author

@buchdag done, added Claude Code as co-author on the commits. The AI-generated flag is already in the PR description.

@JamBalaya56562
JamBalaya56562 force-pushed the fix/nginx-replicas-reload branch from 136faef to 0291955 Compare July 17, 2026 21:44
@JamBalaya56562
JamBalaya56562 force-pushed the fix/nginx-replicas-reload branch from 0291955 to 83e3403 Compare August 8, 2026 22:52
JamBalaya56562 and others added 2 commits August 22, 2026 09:24
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JamBalaya56562
JamBalaya56562 force-pushed the fix/nginx-replicas-reload branch from 83e3403 to 325f2ff Compare August 22, 2026 00:25
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 container setup + nginx replicas

3 participants