[docs] Deploy: Ianitor v1.0.0 beside Caddy on .217 (flower, esp32ide), the exact host-file lines and checks; ROADMAP status and handover

This commit is contained in:
2026-12-02 21:34:51 +01:00
parent 4c157b3347
commit 468e3fe7b8
4 changed files with 295 additions and 2 deletions
+263
View File
@@ -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/<hostname>.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/<id> 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.
+3
View File
@@ -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