From 468e3fe7b875636c597355a48a46ca72489f50ff Mon Sep 17 00:00:00 2001 From: mnovak Date: Wed, 2 Dec 2026 21:34:51 +0100 Subject: [PATCH] [docs] Deploy: Ianitor v1.0.0 beside Caddy on .217 (flower, esp32ide), the exact host-file lines and checks; ROADMAP status and handover --- README.md | 3 +- docs/ROADMAP.md | 28 +++- docs/deploy/beside-caddy-217.md | 263 ++++++++++++++++++++++++++++++++ docs/deploy/beside-caddy.md | 3 + 4 files changed, 295 insertions(+), 2 deletions(-) create mode 100644 docs/deploy/beside-caddy-217.md diff --git a/README.md b/README.md index 465cd0c..993b8b0 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,8 @@ services.ianitor = { Then `ianitor-control token create --name laptop --config /etc/ianitor/control.toml` for the API, or the web UI behind Authelia ([docs/api.md](docs/api.md), "Sign-in"). Beside an existing Caddy, edge can sit behind it on a Unix -socket: [docs/deploy/beside-caddy.md](docs/deploy/beside-caddy.md). The CA: [docs/pki.md](docs/pki.md). +socket: [docs/deploy/beside-caddy.md](docs/deploy/beside-caddy.md) (on .217: +[beside-caddy-217.md](docs/deploy/beside-caddy-217.md)). The CA: [docs/pki.md](docs/pki.md). ## Tests diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 1fec6d3..12ee8b6 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -165,11 +165,37 @@ Identity gate, tunnel, Domi templates, ACME server, HTTP/3, migrating public sit | 1 Core and engine | Done | Merged to main 2026-11-07. Tests run in WSL2; ACME checked only against Pebble. The Let's Encrypt staging check moved to phase 3 (Mark, 2026-11-07). | | 2 Control plane | Done | Merged to main 2026-11-07 (PR 3): routes repo, journaled apply with trial/watch/revert, undo, restore, share links, API tokens, REST API + OpenAPI, `--dev`. Four QC rounds; every finding fixed or listed in Handover. Real Gitea, systemd credentials and Authelia not exercised. | | 3 Web UI, PKI, NixOS | Built and merged; Done criteria pending Mark | Merged to main 2026-11-08 (PR 5): web UI (murex palette), Domi CA and device mTLS, UI sign-in behind Authelia, runtime engine switch with changes under Caddy, NixOS flake, module and VM tests. Click smoke test green. Not yet done: VM tests run on a KVM host, Mark's nixos-rebuild on the staging mirror, deploy/test-access.sh there, the LE staging check. | -| 4 Hardening and release | Built and merged; Done criteria pending Mark | Merged to main 2026-11-22 (PR 13): hardening backlog (header deadline, own resolver, pipelining, proxy socket for edge beside Caddy, control UI socket), all five test layers runnable (fuzz, h2spec/testssl, bench vs Caddy committed as data), Artifex `layers` and `verify-nix` pipelines, a release pin that cannot name other code, README, support.md, launch drafts; with the release kit and Fabrica onboarding (source archive, Aula page, Playwright e2e, 2026-11-19). Not yet done: the first Nix pin and the VM tests (need a machine with Nix and KVM), a pipeline run, signed v1.0.0, the GitHub mirror (later), the two-week run beside Caddy. | +| 4 Hardening and release | Pipeline green, v1.0.0 tagged; signature and the two weeks pending Mark | Merged to main 2026-11-22 (PR 13): hardening backlog, all five test layers, the `layers` and `verify-nix` pipelines, the release pin, README, support.md, launch drafts, the release kit. 2026-12-02 (PR 18): version 1.0.0, the first Nix pin (both outputs rebuilt identical on the NixOS runner), `layers` green on the shared runner (all five layers, VM tests included; run raty64ymvsmbe), v1.0.0 tagged at 4c157b3 and its release started (release run rekp4ztrvy2jr). Not yet done: Mark's release card and the domi-release signature, the run beside Caddy on .217 ([deploy/beside-caddy-217.md](deploy/beside-caddy-217.md), Aula deploys), the GitHub mirror (later). | ## 10. Handover (Rewritten at the end of every session: what changed, what was not verified, which build is deployed, the next step.) +**2026-12-02: v1.0.0: the first Nix pin, the `layers` pipeline green, the tag; .217 prepared (PR 18, then this PR).** +- **Changed:** + - Version 1.0.0; Settings, About shows the running version; `.fabrica/notes/1.0.0.md`. + - `.fabrica/nix/pin.json` from the NixOS runner (`nix-pin.sh --check` prints the pin it would write; docs/release.md 1a). + - The shared runner's first `layers` runs found five things, all fixed: + - control's pki tests need openssl (now in the `ci` shell); + - control's integration tests overload the runner (`RUST_TEST_THREADS=4`); + - the tests' 2 s trial margin was too short there; it is 15 s now (production 30 s), and two tests wait on a state; + - the VM test server had no git; + - bench.sh died silently without `ss` (iproute2 in the `ci` shell; a missing pid is no longer fatal). + - bench/results/2026-12-02-fabrica-runner.csv: on the runner Ianitor is ahead of Caddy in every row; the notes say so, + beside the WSL2 run where Caddy led on HTTP/1.1 under load and new TLS connections. + - docs/deploy/beside-caddy-217.md: the exact lines for .217's nixos-config (input, module, modules/ianitor.nix, + caddy.nix), the secrets, the intermediate, the two host files (flower, esp32ide), the checks and the rollback. +- **Tests:** layers `raty64ymvsmbe`: workspace 267/267 (core 108, edge 71, control 78, diff 4, fuzz 4, testkit 2); + h2spec Ianitor 145/146, 0 failed (Caddy 4 failed); testssl A+ both; fuzz 5x120 s, no crash; the five VM tests; load + and soak. verify-nix `rh5wz4xza5v9x` at the pinned tree: `matches .fabrica/nix/pin.json`. Local: control 78/78 in + WSL, vitest 23, svelte-check clean, release-pin 7. +- **Deployed:** nothing. .217 is unchanged; Aula deploys from beside-caddy-217.md. +- **Not verified:** the module against .217's nixpkgs 24.11 (`nixos-rebuild build` there is the check); the two vhosts' + other lines in caddy.nix; the release's e2e step on the Windows runner (it runs in release run rekp4ztrvy2jr). +- **Needs Mark:** the v1.0.0 release card and the domi-release signature; domi-root.crt (public) for .217; signing the + intermediate CSR offline; confirming flower and esp32ide as the trial hosts; the pki-password into Custos; PR 10 + (t4-anywhere); the 90 % rule in CLAUDE.md, typed by him. +- **Next step:** Aula deploys to .217 from beside-caddy-217.md; test-access.sh passes; the two weeks start (write the date here). + **2026-11-23: Ianitor is CPAL-1.0 (Mark's decision for every public Domi repo; F:\Akce\domi-licence).** - **Changed:** LICENSE is the kit's template with only `{ORIGINAL_CODE}` = Ianitor. Every header (166 files) is an `SPDX-License-Identifier: CPAL-1.0` notice; Cargo.toml, the fuzz crate, the three package.json, the Nix package diff --git a/docs/deploy/beside-caddy-217.md b/docs/deploy/beside-caddy-217.md new file mode 100644 index 0000000..341e1b7 --- /dev/null +++ b/docs/deploy/beside-caddy-217.md @@ -0,0 +1,263 @@ +# Ianitor beside Caddy on .217: two hosts for two weeks + +This is ROADMAP §1.12 on the production server (192.168.100.217), in the shape of [beside-caddy.md](beside-caddy.md): +Caddy keeps 80/443 and its certificates, and for two low-risk hosts it hands each request to Ianitor's edge on a Unix +socket. Every other host stays as it is. **Prepared, not applied.** Every command here runs on .217 by Mark, or by +Aula, which deploys there for him; Ianitor's own sessions never touch .217. The code arrives as a git bundle (.217 +has no Gitea credentials). + +The facts below are from .217's config as read on 2026-12-02 (flake `/home/apps/nixos-config`, output `.#nixos-vm`, +nixpkgs 24.11, Caddy from nixos-unstable, no sops: secrets are root-only files). + +## The two hosts + +| Host | Today in Caddy | Why it is low-risk | +| :-- | :-- | :-- | +| `flower.marek-novak.cz` | `reverse_proxy 127.0.0.1:8092` | a static presentation app, no sign-in | +| `esp32ide.marek-novak.cz` | `reverse_proxy 127.0.0.1:8082` | a static web IDE, used only by Mark, no sign-in | + +```text +visitor ── Caddy :443 (Let's Encrypt, as today) ── unix//run/ianitor-proxy/edge.sock ── Ianitor edge ── the app +``` + +Nothing new listens beyond loopback: edge's TCP listeners are 127.0.0.1:18080 and :18443, control is 127.0.0.1:7878 +and its UI socket. Before the switch, check these are free: `ss -ltn | grep -E ':(18080|18443|7878)\b'` prints +nothing. + +## 1. Bring the code over (Ianitor v1.0.0) + +On a machine with Gitea access: `git clone --mirror https://gitea.marek-novak.cz/mnovak/ianitor.git && git -C +ianitor.git bundle create ianitor-v1.0.0.bundle v1.0.0`. On .217, as `apps`: + +```sh +git clone --branch v1.0.0 ianitor-v1.0.0.bundle /home/apps/ianitor +git -C /home/apps/ianitor rev-parse 'v1.0.0^{commit}' # must print 4c157b334779b27171f62029671e9e2478e37717 +``` + +That commit's Nix outputs are pinned in its `.fabrica/nix/pin.json` (ianitor `sha256-hlX5oiJQ…`, ianitor-web +`sha256-cR8Lq5LN…`); `nix path-info --json` of the switched system's Ianitor can be compared with it +([../verify.md](../verify.md)). + +The build fetches one git dependency, domi-pki, from `https://gitea.marek-novak.cz/mnovak/domi-pki` (public, no +credentials; a fixed-output fetch checked by its hash). Everything else comes from cache.nixos.org and crates.io. + +## 2. flake.nix (three lines) + +In `inputs`, after `aula.inputs.fundamentum.url`: + +```nix + # Ianitor Domi: the Pingora reverse proxy, beside Caddy on flower and esp32ide. A local clone at the tag. + # Update: bring the next tag as a bundle, then nix flake lock --update-input ianitor + ianitor.url = "git+file:///home/apps/ianitor?ref=refs/tags/v1.0.0"; +``` + +In `nixosConfigurations."nixos-vm"`'s `modules`, after `./modules/aula.nix`: + +```nix + inputs.ianitor.nixosModules.default + ./modules/ianitor.nix +``` + +Ianitor's packages build from its own pinned nixpkgs (26.05); only the module is evaluated against .217's 24.11. + +## 3. modules/ianitor.nix (new; `git add` it, or the flake does not see it) + +```nix +{ ... }: + +# Ianitor beside Caddy (Ianitor docs/deploy/beside-caddy-217.md): flower and esp32ide go through Ianitor's edge; +# every other host stays on Caddy. Rollback: remove this file's two lines in flake.nix and the two socket lines in +# caddy.nix, then nixos-rebuild switch. +{ + services.ianitor = { + enable = true; + edge = { + httpListen = "127.0.0.1:18080"; + httpsListen = "127.0.0.1:18443"; + openFirewall = false; + # Caddy reaches edge on /run/ianitor-proxy/edge.sock; only Caddy joins the socket's group. `services` + # puts the group into Caddy's unit, so the switch restarts Caddy with it (a reload would keep old groups). + proxySocket = { enable = true; users = [ "caddy" ]; services = [ "caddy" ]; }; + }; + control.listen = "127.0.0.1:7878"; + # Root-only files outside the store (step 4); the module refuses a /nix/store path. + shareLinkKeyFile = "/var/lib/ianitor-secrets/share-link-key"; + pki = { + enable = true; + # The Domi root's certificate (public). The root key never comes to the server. + rootCertificate = ./ianitor/domi-root.crt; + passwordFile = "/var/lib/ianitor-secrets/pki-password"; + }; + }; +} +``` + +`modules/ianitor/domi-root.crt`: the public certificate of the Domi root (`git add` it too). + +## 4. The two secrets (once, before the switch) + +Generated on the server and never shown: + +```sh +sudo install -d -m 0700 -o root -g root /var/lib/ianitor-secrets +for k in share-link-key pki-password; do + sudo sh -c "umask 077; head -c 32 /dev/urandom | base64 -w0 > /var/lib/ianitor-secrets/$k" +done +sudo ls -l /var/lib/ianitor-secrets # two files, -rw------- root root, 44 bytes each +``` + +Offer `pki-password` to Custos the way the other apps' secrets are (`custos-provision offer …`): without it the +intermediate and device keys cannot be opened after a restore. + +## 5. caddy.nix (two lines) + +In the `flower.marek-novak.cz` vhost, replace `reverse_proxy 127.0.0.1:8092` with: + +```caddy +reverse_proxy unix//run/ianitor-proxy/edge.sock +``` + +In the `esp32ide.marek-novak.cz` vhost, replace `reverse_proxy 127.0.0.1:8082` with the same line. Leave every other +line of both vhosts (TLS, headers, logs) as it is. Keep the old line as a comment for the rollback. + +## 6. Switch + +```sh +cd /home/apps/nixos-config +nix flake lock --update-input ianitor +sudo nixos-rebuild build --flake .#nixos-vm # build first +sudo nixos-rebuild switch --flake .#nixos-vm +``` + +Then check that Caddy runs with the socket's group (else edge answers it EACCES, a 502 on both hosts): + +```sh +gid=$(getent group ianitor-proxy | cut -d: -f3) +grep "^Groups:" /proc/$(systemctl show -p MainPID --value caddy)/status | grep -qw "$gid" \ + || sudo systemctl restart caddy +systemctl is-active ianitor-edge ianitor-control caddy # active ×3 +``` + +Until step 7 the two hosts answer 502 from Caddy (edge has no routes yet). To keep that window short, do step 7 +straight after the switch; to avoid it, switch the caddy.nix lines in a second rebuild after step 7. + +## 7. The intermediate and the two host files + +On .217, as root (`sudo -i`); control listens on 127.0.0.1 only, so no tunnel is needed. The API token goes +straight into a root-only header file and is never shown, on a command line (ps) or in the shell history: + +```sh +( umask 077 + t=$(runuser -u ianitor-control -- ianitor-control token create --name aula-217 --config /etc/ianitor/control.toml) + printf 'Authorization: Bearer %s\n' "$t" > /root/.ianitor-header ) +H=@/root/.ianitor-header; API=http://127.0.0.1:7878/api/v1 +curl -s -H "$H" "$API/engine" | jq -c '{running, state}' # {"running":"pingora","state":"running"} + +# The intermediate's CSR and its extensions, for Mark's offline signing (docs/pki.md): +install -d -m 0700 /root/ianitor-csr +curl -s -H "$H" -X POST "$API/certs/intermediate/renewal" | jq -r .csr_pem > /root/ianitor-csr/req.csr +curl -s -H "$H" "$API/pki-requests/$(curl -s -H "$H" "$API/overview" | jq -r .intermediate.renewal.request_id)/ext" \ + > /root/ianitor-csr/req.ext +``` + +Mark signs it offline with the Domi root, the same openssl line as in [beside-caddy.md](beside-caddy.md): +`openssl x509 -req -in req.csr -CA domi-root.crt -CAkey domi-root.key -days 365 -sha256 -extfile req.ext -out +int.crt`. `int.crt` (public) comes back to .217 as `/tmp/int.crt`: + +```sh +runuser -u ianitor-control -- ianitor-control pki install /tmp/int.crt --config /etc/ianitor/control.toml +``` + +The host files Ianitor commits to its routes repository (`hosts/.toml`), as JSON for the API +(`POST $API/hosts` with `{"host": …}`): + +```toml +# hosts/flower.marek-novak.cz.toml +hostname = "flower.marek-novak.cz" +upstreams = ["http://127.0.0.1:8092"] +tls = "domi" +auth = "none" + +[health_check] +path = "/" +interval_secs = 30 + +[[response_headers]] +action = "set" +name = "X-Served-By" +value = "ianitor" +``` + +```toml +# hosts/esp32ide.marek-novak.cz.toml +hostname = "esp32ide.marek-novak.cz" +upstreams = ["http://127.0.0.1:8082"] +tls = "domi" +auth = "none" + +[health_check] +path = "/" +interval_secs = 30 + +[[response_headers]] +action = "set" +name = "X-Served-By" +value = "ianitor" +``` + +```sh +for h in flower:8092 esp32ide:8082; do + curl -s -H "$H" -H 'Content-Type: application/json' -X POST "$API/hosts" -d "$(jq -cn \ + --arg h "${h%%:*}.marek-novak.cz" --arg u "http://127.0.0.1:${h##*:}" \ + '{host: {hostname: $h, upstreams: [$u], tls: "domi", auth: "none", + health_check: {path: "/", interval_secs: 30}, + response_headers: [{action: "set", name: "X-Served-By", value: "ianitor"}]}}')" +done # each answers 202 with an apply; GET $API/applies/ until "kept" +``` + +(`tls = "domi"` is edge's own loopback listener; visitors keep Caddy's Let's Encrypt certificate.) + +## 8. Checks + +On .217: + +```sh +ss -ltnp | grep -E 'ianitor' # only 127.0.0.1:18080, 127.0.0.1:18443 and 127.0.0.1:7878 +for h in flower esp32ide; do + sudo curl -s -o /dev/null -w "$h %{http_code}\n" --unix-socket /run/ianitor-proxy/edge.sock \ + -H "Host: $h.marek-novak.cz" http://localhost/ +done # 200 (or the app's 3xx) for both +``` + +From the desktop (192.168.100.140), with the repository at the tag: + +```sh +deploy/test-access.sh --server 192.168.100.217 \ + --public gitea.marek-novak.cz \ + --via-ianitor flower.marek-novak.cz --via-ianitor esp32ide.marek-novak.cz +``` + +(`--public` needs a host that answers 2xx or 3xx without a sign-in redirect; gitea's front page does. Hosts behind +Authelia do not belong there.) + +It must print `all checks passed`: both hosts answer through Ianitor (`X-Served-By: ianitor`), an untouched host +still answers, and control's port does not answer from the LAN. The two weeks start then; write the date in +ROADMAP §9. + +**Every day of the two weeks** (an incident is any failed line): + +```sh +for h in flower esp32ide; do curl -sI https://$h.marek-novak.cz/ | grep -qi '^x-served-by: ianitor' && echo "$h ok" || echo "$h FAIL"; done +journalctl -u ianitor-edge -u ianitor-control --since yesterday -p warning --no-pager | tail -20 +``` + +## Rollback + +Put back the two `reverse_proxy 127.0.0.1:…` lines in caddy.nix and `sudo nixos-rebuild switch --flake .#nixos-vm`: +the two hosts are on Caddy alone again within seconds. To remove Ianitor entirely, also drop its two module lines and +the input. `/var/lib/ianitor` and `/var/lib/ianitor-secrets` stay and are ignored. + +## Not verified + +- The module evaluated against nixpkgs 24.11 (the VM tests use Ianitor's 26.05). `nixos-rebuild build` is the check. +- The two vhosts' other lines: only their `reverse_proxy` lines were read. diff --git a/docs/deploy/beside-caddy.md b/docs/deploy/beside-caddy.md index 5a0ea1f..fbbf74b 100644 --- a/docs/deploy/beside-caddy.md +++ b/docs/deploy/beside-caddy.md @@ -3,6 +3,9 @@ ROADMAP §1.12 and §6 Phase 3: Ianitor runs beside Caddy on two low-risk hosts before any cut-over. This is **prepared, not applied**: Mark runs every command below himself. +This file is the staging mirror's plan (Configuration_Server, 2026-11-07). The run on the production server .217 +(nixos-config, flower and esp32ide, v1.0.0) is [beside-caddy-217.md](beside-caddy-217.md). + ## What was found in Configuration_Server (read-only, 2026-11-07) - `hyperv-infra/` is the active flake (`nixosConfigurations.hyperv-vm`, the staging mirror on -- 2.53.0