[repo] NixOS and docs: ianitor-caddy-guard with caddy-fallback, caddy-revert after every control stop, admin socket only for control, Caddy trial deadline in the engine-switch VM test, trusted proxies stay off beside Caddy

This commit is contained in:
2026-11-08 12:04:14 +01:00
parent 23a283ece9
commit 457aea86ca
6 changed files with 80 additions and 13 deletions
+18 -6
View File
@@ -316,15 +316,27 @@ Refusals: `engine.unmanaged` (no `[engine]` in control.toml), `engine.same`, `en
While Caddy serves (decisions Q3, Q4; Mark 2026-11-08):
- **changes keep working**: applies, Undo and Restore go through the same pipeline. Both outputs
are compiled; the trial is loaded into Caddy through its admin API (`POST /load` on the Unix
socket `[compile_caddy] caddy_admin_socket`, `/run/caddy-fallback/admin.sock` under NixOS), the
touched hosts are probed *through Caddy* for the watch window, and a revert loads the previous
`caddy.json` again. Without `caddy_admin_socket` an apply under Caddy fails with
`apply.failed.reload` and nothing changes;
socket `[compile_caddy] caddy_admin_socket`, `/run/caddy-fallback/admin.sock` under NixOS,
group `ianitor-caddy-admin`: control and Caddy, not edge), and a revert loads the previous
`caddy.json` again. Every load sends `Cache-Control: must-revalidate`, so Caddy reads its
certificate and device files again even when the config is unchanged. The watch judges health
as edge does: control probes the upstreams itself with edge's rules (health check: `GET <path>`,
Host = the upstream, 2xx; none: `GET /`, Host = the hostname, below 500), and a probe *through*
Caddy only asks that Caddy answers at all (any status, its sign-in redirect included). Each
round also checks that Caddy still runs the trial (`GET /config/`); if anything else reloaded it,
the change is undone as `apply.reverted.edge_lost`. Without `caddy_admin_socket` an apply under
Caddy fails with `apply.failed.reload` and nothing changes;
- **an unconfirmed trial never outlives control**, as with edge: control arms a deadline
(`caddy-trial.json` in its state directory: watch + margin) before loading the trial and claims
it before confirming. `ianitor-caddy-guard` (a unit that runs with caddy-fallback,
`ianitor-control caddy-guard`) reverts a trial past its deadline, which covers a hung control;
ianitor-control's `ExecStopPost=ianitor-control caddy-revert` reverts at once after any stop or
crash. Whoever renames the deadline file first wins, so a trial is either kept or reverted;
- device issues and revocations wait for a running apply, then reload Caddy and check that it
serves the certificate on disk for a Domi host (else `devices_problem`, retried);
- **share links are off**: minting is `409 share.engine_caddy`, and a visitor with a link gets the
normal sign-in (fails closed). Caddy cannot check a share token and control never serves
visitors; a validator Caddy calls through `forward_auth` is planned before v1.1;
- device issues and revocations reload Caddy through the same socket (Caddy reads the allow list
when a config is loaded).
A revocation is in force only once the serving engine has the new list. If the list cannot be
written or the engine does not take it, `DELETE /certs/devices/{id}` answers `503
+8
View File
@@ -32,6 +32,14 @@ visitor ── Caddy :443 (as today) ── https://127.0.0.1:18443 Ianitor edg
- Caddy keeps the public side for the two names and hands them to Ianitor over TLS; Ianitor
serves them with Domi certificates, which Caddy checks against the Domi root (a public file).
- Every other host is untouched. Rollback: revert the patch and switch (below).
- Visitor addresses: Ianitor sees every visit coming from 127.0.0.1 (Caddy), so the share-link
throttle counts all visitors together and the visit log shows 127.0.0.0. The option
`services.ianitor.edge.trustedProxies = [ "127.0.0.1" ]` would make edge believe Caddy's
`X-Forwarded-For` instead, but edge listens on a TCP port on loopback that **any local user or
process can reach**, and any of them could then claim any address. It stays **off** for the
trial (the two hosts have no share links and no visit log); turn it on only on a machine where
every local account is trusted. (A Unix-socket listener for edge, which Caddy alone could reach,
is the proper fix; not built yet.)
## The patch
+1 -3
View File
@@ -67,7 +67,7 @@ new file mode 100644
index 0000000..cd23016
--- /dev/null
+++ b/hyperv-infra/modules/ianitor.nix
@@ -0,0 +1,51 @@
@@ -0,0 +1,49 @@
+{ config, lib, inputs, ... }:
+
+# Ianitor beside Caddy (Ianitor ROADMAP §1.12, Phase 3): two low-risk hosts, flowers and esp32,
@@ -100,8 +100,6 @@ index 0000000..cd23016
+ httpListen = "127.0.0.1:18080";
+ httpsListen = "127.0.0.1:18443";
+ openFirewall = false;
+ # Caddy in front, on loopback: its X-Forwarded-For names the visitor (throttle, logs).
+ trustedProxies = [ "127.0.0.1" ];
+ };
+ control.listen = "127.0.0.1:7878";
+ shareLinkKeyFile = config.sops.secrets."ianitor/share-link-key".path;
+2 -1
View File
@@ -545,4 +545,5 @@ Recorded by the Phase 3 implementation (branch `phase-3`); docs/api.md has the c
10 minutes.
- New host field `device_certs` (bool): only Domi device certificates on the allow list get in.
- `overview.paused_reason` gives the underlying code (`apply.needs_attention`,
`control.files_unwritten`, `repo.*`) next to `paused {code: "control.paused"}`.
`control.files_unwritten`, `repo.*`) next to `paused {code: "control.paused"}`, and
`overview.paused_detail` the technical detail behind it (for "Show details").