files-healthy: nginx (Nextcloud's web frontend) can never bind :80 — Caddy already owns it, so Files stays "not ready" #529

Closed
opened 2026-08-14 15:48:01 +00:00 by ben · 3 comments
Owner

Failure

The #183 rehearsal drive went RED at the files-healthy leg (artifacts/legs.json:97-102), 39ms after the deploy-files leg reported green:

{
  "leg": "files-healthy",
  "status": "red",
  "ms": 39,
  "error": "[data-field=\"service-files\"] is absent but services-health is present — a failure is standing that named a different service: Files & documentsFAILEDFiles & documents is not serving — Nextcloud reports it is not ready — this service is not doing its job Retry Files & documents Remove"
}

error-context.md confirms the same assertion failure (expectFilesHealthy, tests/e2e/journey.droplet.spec.ts:374) and shows the Active screen (S5) rendering the founding-bar trio correctly — this is not a UI/harness timing miss, the app itself is reporting the files service as failed.

Root cause (droplet's own systemd journal)

logs/droplet-journal.txt shows two NixOS switch-to-configuration runs on the droplet. The first (15:39:55–15:40:33, adding the control-plane) succeeds cleanly. The second — the one that lands the files/Nextcloud service, matching the deploy-files leg's ~231s duration and ending exactly at 15:45:00 — brings up nginx.service for the first time, and it never binds successfully:

Aug 14 15:44:41 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 14 15:44:41 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: bind() to [::]:80 failed (98: Address already in use)
...
Aug 14 15:44:43 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: still could not bind()
Aug 14 15:44:43 gateway systemd[1]: nginx.service: Main process exited, code=exited, status=1/FAILURE
Aug 14 15:44:43 gateway systemd[1]: nginx.service: Failed with result 'exit-code'.

nginx retries twice more (restart counter 1, then a client-requested restart during the second switch attempt) and fails every single time with the identical Address already in use on both 0.0.0.0:80 and [::]:80, right up through 15:45:01 — after the NixOS switch itself is reported "finished" (clan-switch-gateway-a8bd3105.service: Deactivated successfully, 15:45:00). So the activation completes, but nginx is left permanently down.

The only other process holding port 80 on this host is Caddy, the community's single public front door, started earlier and never restarted or crashed:

Aug 14 15:39:26 gateway systemd[1]: Starting Caddy...
Aug 14 15:39:26 gateway systemd[1]: Started Caddy.

Meanwhile nextcloud-setup.service, php-fpm, and the brand-kit occ calls all completed successfully (Nextcloud was successfully installed, [NOTICE] fpm is running, pid 8541, [NOTICE] ready to handle connections) — the PHP application layer is fine. It's the HTTP frontend in front of PHP-FPM (the NixOS services.nginx vhost the Nextcloud module wires up) that's dead, because it's fighting Caddy for :80. With nginx down, nothing serves files.rehearsal.idss.nz on the expected path, so the control-plane's own Nextcloud health probe correctly reports the service as not ready, and the Active screen surfaces exactly that: "Files & documents is not serving — Nextcloud reports it is not ready."

Suspected layer

Product — the gateway's NixOS module composition. Enabling the files/Nextcloud service adds a nginx.service that listens on 0.0.0.0:80/[::]:80 unconditionally, without accounting for Caddy already owning port 80 as the community's sole front door. This isn't a flaky timing issue or a harness gap — the port conflict is deterministic and total (0/3 bind attempts succeeded), and it's an infra-layer regression, not a Nextcloud application defect.

What plugging it needs

Someone with access to the gateway's Nix module (the composition that turns on services.nginx for the files/Nextcloud role) needs to either:

  • stop that module from binding nginx to the wildcard :80/[::]:80 — bind it to localhost or a private port instead, with Caddy reverse-proxying to it (matching how the rest of the fleet's services are fronted), or
  • confirm Caddy is meant to hand files.<apex> traffic straight to PHP-FPM without an intermediate nginx, and disable/remove the module's nginx vhost for this role entirely.

Either fix is scoped and actionable without a human ruling on product behavior — the invariant ("Caddy is the one public :80 listener") is already established elsewhere in this journal (Caddy started once at boot, never conflicted, never restarted).

Not the known frontier

This is not the known own-VPS pairing frontier (legs.json's skip-reason class where pairing never flips) — pair (19ms), mesh (13ms), and public-entry (14ms) all went green with no skip markers in legs.json. This is a new, distinct RED at files-healthy, three legs past pairing.

Absent evidence

All logs/guest-*.log and logs/qemu.log files are empty/error stubs (Failed to connect to bus, No such file or directory, ps -C qemu-system-x86_64 finding nothing) — expected for a drive-droplet run, which drives a real DigitalOcean droplet rather than a local qemu guest, so these collectors have nothing to gather. artifacts/journey.json has rows: null, fault: null — the founding-rows capture wasn't populated for this run (or founding hadn't reached a capturable point when it snapshotted); it adds nothing beyond logs/founding-state.log, which independently confirms founding completed through hand-off before the drive continued into the files leg.

drive 20260814T153243Z red at files-healthy: [data-field="service-files"] is absent but services-health is present — a failure is standing that named a different service: Files & documentsFAILEDFiles & documents is not serving — Nextcloud re
evidence: test-results/…/20260814T153243Z/ on matou-workstation (legs.json, droplet-journal.txt, trace)

## Failure The `#183` rehearsal drive went RED at the **files-healthy** leg (`artifacts/legs.json:97-102`), 39ms after the `deploy-files` leg reported green: ```json { "leg": "files-healthy", "status": "red", "ms": 39, "error": "[data-field=\"service-files\"] is absent but services-health is present — a failure is standing that named a different service: Files & documentsFAILEDFiles & documents is not serving — Nextcloud reports it is not ready — this service is not doing its job Retry Files & documents Remove" } ``` `error-context.md` confirms the same assertion failure (`expectFilesHealthy`, `tests/e2e/journey.droplet.spec.ts:374`) and shows the Active screen (S5) rendering the founding-bar trio correctly — this is not a UI/harness timing miss, the app itself is reporting the files service as failed. ## Root cause (droplet's own systemd journal) `logs/droplet-journal.txt` shows **two** NixOS `switch-to-configuration` runs on the droplet. The first (15:39:55–15:40:33, adding the control-plane) succeeds cleanly. The second — the one that lands the files/Nextcloud service, matching the `deploy-files` leg's ~231s duration and ending exactly at 15:45:00 — brings up `nginx.service` for the first time, and it **never binds successfully**: ``` Aug 14 15:44:41 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: bind() to 0.0.0.0:80 failed (98: Address already in use) Aug 14 15:44:41 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: bind() to [::]:80 failed (98: Address already in use) ... Aug 14 15:44:43 gateway nginx[8389]: 2026/08/14 15:44:41 [emerg] 8389#8389: still could not bind() Aug 14 15:44:43 gateway systemd[1]: nginx.service: Main process exited, code=exited, status=1/FAILURE Aug 14 15:44:43 gateway systemd[1]: nginx.service: Failed with result 'exit-code'. ``` nginx retries twice more (restart counter 1, then a client-requested restart during the second switch attempt) and fails **every single time** with the identical `Address already in use` on both `0.0.0.0:80` and `[::]:80`, right up through 15:45:01 — after the NixOS switch itself is reported "finished" (`clan-switch-gateway-a8bd3105.service: Deactivated successfully`, 15:45:00). So the activation completes, but nginx is left permanently down. The only other process holding port 80 on this host is **Caddy**, the community's single public front door, started earlier and never restarted or crashed: ``` Aug 14 15:39:26 gateway systemd[1]: Starting Caddy... Aug 14 15:39:26 gateway systemd[1]: Started Caddy. ``` Meanwhile `nextcloud-setup.service`, `php-fpm`, and the brand-kit `occ` calls all completed successfully (`Nextcloud was successfully installed`, `[NOTICE] fpm is running, pid 8541`, `[NOTICE] ready to handle connections`) — the PHP application layer is fine. It's the HTTP frontend in front of PHP-FPM (the NixOS `services.nginx` vhost the Nextcloud module wires up) that's dead, because it's fighting Caddy for `:80`. With nginx down, nothing serves `files.rehearsal.idss.nz` on the expected path, so the control-plane's own Nextcloud health probe correctly reports the service as not ready, and the Active screen surfaces exactly that: "Files & documents is not serving — Nextcloud reports it is not ready." ## Suspected layer **Product** — the gateway's NixOS module composition. Enabling the files/Nextcloud service adds a `nginx.service` that listens on `0.0.0.0:80`/`[::]:80` unconditionally, without accounting for Caddy already owning port 80 as the community's sole front door. This isn't a flaky timing issue or a harness gap — the port conflict is deterministic and total (0/3 bind attempts succeeded), and it's an infra-layer regression, not a Nextcloud application defect. ## What plugging it needs Someone with access to the gateway's Nix module (the composition that turns on `services.nginx` for the files/Nextcloud role) needs to either: - stop that module from binding nginx to the wildcard `:80`/`[::]:80` — bind it to localhost or a private port instead, with Caddy reverse-proxying to it (matching how the rest of the fleet's services are fronted), or - confirm Caddy is meant to hand `files.<apex>` traffic straight to PHP-FPM without an intermediate nginx, and disable/remove the module's nginx vhost for this role entirely. Either fix is scoped and actionable without a human ruling on product behavior — the invariant ("Caddy is the one public :80 listener") is already established elsewhere in this journal (Caddy started once at boot, never conflicted, never restarted). ## Not the known frontier This is **not** the known own-VPS pairing frontier (`legs.json`'s skip-reason class where pairing never flips) — `pair` (19ms), `mesh` (13ms), and `public-entry` (14ms) all went green with no skip markers in `legs.json`. This is a new, distinct RED at `files-healthy`, three legs past pairing. ## Absent evidence All `logs/guest-*.log` and `logs/qemu.log` files are empty/error stubs (`Failed to connect to bus`, `No such file or directory`, `ps -C qemu-system-x86_64` finding nothing) — expected for a `drive-droplet` run, which drives a real DigitalOcean droplet rather than a local qemu guest, so these collectors have nothing to gather. `artifacts/journey.json` has `rows: null, fault: null` — the founding-rows capture wasn't populated for this run (or founding hadn't reached a capturable point when it snapshotted); it adds nothing beyond `logs/founding-state.log`, which independently confirms founding completed through hand-off before the drive continued into the files leg. drive `20260814T153243Z` red at `files-healthy`: `[data-field="service-files"] is absent but services-health is present — a failure is standing that named a different service: Files & documentsFAILEDFiles & documents is not serving — Nextcloud re` evidence: `test-results/…/20260814T153243Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) <!-- rehearsal-sig: 1e68ed8f0b94 -->
Author
Owner

⚠️ TRAP for the fix — verified live before you pick the port: the natural fix (apply FilesConfig.LoopbackPort = NextcloudLoopbackPort on the own-VPS co-host, as the private path does) walks straight into a SECOND collision. NextcloudLoopbackPort = 8081 (internal/clan/files.go:88) — and on the own-VPS gateway acme-dns's HTTP API already owns 127.0.0.1:8081, from this very drive's journal:

Aug 14 15:39:25 gateway acme-dns[984]: Listening HTTP {"host": "127.0.0.1:8081"}

The private path co-hosts happily on 8081 only because it runs no acme-dns (guest CA, no ACME). Set it to 8081 here and nginx dies EADDRINUSE on 8081 instead of 80 — same red, one drive later.

So the fix is two-part:

  1. Apply the loopback override whenever the files node IS the front-door node (true co-host detection, path-independent) — the missing wiring this ticket names.
  2. Move NextcloudLoopbackPort off 8081 to an unclaimed loopback port, updating NextcloudLoopbackTarget with it (they're deliberately adjacent so they can't drift). Known claims on the own-VPS gateway to avoid: 8080 (control plane), 8081 (acme-dns API), 8443 (kanidm loopback). Check gatewayFleetPorts() (vmguest.go) and the other service renders for the rest before choosing, and leave a comment at the constant naming the neighbours so the next port lands clean. Private-path pins re-pin with the constant — deployments are ephemeral, no migration concern.

Evidence for part 1 from the same journal: nginx bound its DEFAULT 0.0.0.0:80 / [::]:80 (not a loopback port) → EADDRINUSE against Caddy → nginx.service failed — i.e. the override was never rendered on this path.

⚠️ **TRAP for the fix — verified live before you pick the port**: the natural fix (apply `FilesConfig.LoopbackPort = NextcloudLoopbackPort` on the own-VPS co-host, as the private path does) walks straight into a SECOND collision. `NextcloudLoopbackPort = 8081` (internal/clan/files.go:88) — and on the own-VPS gateway **acme-dns's HTTP API already owns 127.0.0.1:8081**, from this very drive's journal: ``` Aug 14 15:39:25 gateway acme-dns[984]: Listening HTTP {"host": "127.0.0.1:8081"} ``` The private path co-hosts happily on 8081 only because it runs no acme-dns (guest CA, no ACME). Set it to 8081 here and nginx dies EADDRINUSE on 8081 instead of 80 — same red, one drive later. So the fix is two-part: 1. **Apply the loopback override whenever the files node IS the front-door node** (true co-host detection, path-independent) — the missing wiring this ticket names. 2. **Move `NextcloudLoopbackPort` off 8081 to an unclaimed loopback port**, updating `NextcloudLoopbackTarget` with it (they're deliberately adjacent so they can't drift). Known claims on the own-VPS gateway to avoid: 8080 (control plane), 8081 (acme-dns API), 8443 (kanidm loopback). Check `gatewayFleetPorts()` (vmguest.go) and the other service renders for the rest before choosing, and leave a comment at the constant naming the neighbours so the next port lands clean. Private-path pins re-pin with the constant — deployments are ephemeral, no migration concern. Evidence for part 1 from the same journal: nginx bound its DEFAULT `0.0.0.0:80` / `[::]:80` (not a loopback port) → EADDRINUSE against Caddy → nginx.service failed — i.e. the override was never rendered on this path.
Author
Owner

swarm-claim host=elitebook-distributed-server-03 run=6117
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=6117 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

close-report for #529 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 529,
  "status": "success",
  "commits": [
    "8db963b"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/files.go",
    "internal/clan/files_test.go",
    "internal/provision/deploy.go",
    "internal/provision/deploy_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/clan/ ./internal/provision/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go test ./control-plane/... ./internal/founding/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Stop the module binding nginx to wildcard :80 — bind it to loopback with Caddy reverse-proxying (per Ben's live ruling on-thread)": "internal/provision/deploy.go filesLiveSet now sets FilesConfig.LoopbackPort whenever coHosted (path-independent true co-host detection), not only when o.privateFrontDoor — so the own-VPS (public) gateway's nginx moves off :80; render pinned by internal/clan/files.go renderNextcloudLoopback + TestRenderFiles_CoHostedBindsNginxLoopback",
    "Avoid the second collision Ben flagged: NextcloudLoopbackPort=8081 clashes with acme-dns's HTTP API on the own-VPS gateway": "internal/clan/files.go: NextcloudLoopbackPort 8081->8084 and NextcloudLoopbackTarget re-pinned to 127.0.0.1:8084, with the gateway loopback neighbours (8080/8081/8082/8083/8443) commented at the constant; files_test.go pins the 8084 listen",
    "Regression coverage the invariant 'Caddy is the one public :80 listener'": "TestDeploy_PublicGatewayFilesBindsLoopbackButAddsNoPrivateRoute — a public co-host binds nginx to loopback yet adds no private front-door route",
    "Operational hazard recorded (ADR 0160)": "docs/GOTCHAS.md #31 (Symptom/Cause/Rule) + STATUS.md header and milestone log updated in the same commit"
  },
  "summary": "The files co-host's nginx-off-:80-to-loopback move now keys off true co-host detection (path-independent), and NextcloudLoopbackPort moves 8081->8084 to dodge the own-VPS acme-dns API, so the gateway's nginx stops fighting Caddy for :80.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #529 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 529, "status": "success", "commits": [ "8db963b" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/files.go", "internal/clan/files_test.go", "internal/provision/deploy.go", "internal/provision/deploy_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/clan/ ./internal/provision/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go test ./control-plane/... ./internal/founding/...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 } ], "criteria": { "Stop the module binding nginx to wildcard :80 — bind it to loopback with Caddy reverse-proxying (per Ben's live ruling on-thread)": "internal/provision/deploy.go filesLiveSet now sets FilesConfig.LoopbackPort whenever coHosted (path-independent true co-host detection), not only when o.privateFrontDoor — so the own-VPS (public) gateway's nginx moves off :80; render pinned by internal/clan/files.go renderNextcloudLoopback + TestRenderFiles_CoHostedBindsNginxLoopback", "Avoid the second collision Ben flagged: NextcloudLoopbackPort=8081 clashes with acme-dns's HTTP API on the own-VPS gateway": "internal/clan/files.go: NextcloudLoopbackPort 8081->8084 and NextcloudLoopbackTarget re-pinned to 127.0.0.1:8084, with the gateway loopback neighbours (8080/8081/8082/8083/8443) commented at the constant; files_test.go pins the 8084 listen", "Regression coverage the invariant 'Caddy is the one public :80 listener'": "TestDeploy_PublicGatewayFilesBindsLoopbackButAddsNoPrivateRoute — a public co-host binds nginx to loopback yet adds no private front-door route", "Operational hazard recorded (ADR 0160)": "docs/GOTCHAS.md #31 (Symptom/Cause/Rule) + STATUS.md header and milestone log updated in the same commit" }, "summary": "The files co-host's nginx-off-:80-to-loopback move now keys off true co-host detection (path-independent), and NextcloudLoopbackPort moves 8081->8084 to dodge the own-VPS acme-dns API, so the gateway's nginx stops fighting Caddy for :80.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
ben closed this issue 2026-08-14 16:04:18 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#529
No description provided.