[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:
+30
-3
@@ -151,7 +151,7 @@ in
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [ "127.0.0.1" ];
|
||||
description = "Proxies in front of edge whose X-Forwarded-For names the client (beside Caddy: 127.0.0.1), for the share-link throttle and the access log. Off by default.";
|
||||
description = "Proxies in front of edge whose X-Forwarded-For names the client (beside Caddy: 127.0.0.1), for the share-link throttle and the access log. Off by default: on a loopback listener any local process could then claim any address (docs/deploy/beside-caddy.md).";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -252,7 +252,9 @@ in
|
||||
}) userCreds;
|
||||
|
||||
users.groups.ianitor = { };
|
||||
users.users.ianitor-control = { isSystemUser = true; group = "ianitor"; home = "${stateRoot}/control"; };
|
||||
# Only control (and Caddy itself) may reach Caddy's admin socket; edge is not in it.
|
||||
users.groups.ianitor-caddy-admin = { };
|
||||
users.users.ianitor-control = { isSystemUser = true; group = "ianitor"; extraGroups = [ "ianitor-caddy-admin" ]; home = "${stateRoot}/control"; };
|
||||
users.users.ianitor-edge = { isSystemUser = true; group = "ianitor"; };
|
||||
users.users.caddy-fallback = { isSystemUser = true; group = "ianitor"; };
|
||||
|
||||
@@ -300,6 +302,10 @@ in
|
||||
User = "ianitor-control";
|
||||
Group = "ianitor";
|
||||
ExecStart = "${pkg}/bin/ianitor-control --config ${controlToml}";
|
||||
# After every stop, a crash included: a trial still loaded into Caddy goes back to the
|
||||
# last good caddy.json at once (ianitor_control::caddy_guard). It runs after a crash
|
||||
# too, so no separate OnFailure= unit is needed.
|
||||
ExecStopPost = "${pkg}/bin/ianitor-control caddy-revert --config ${controlToml}";
|
||||
LoadCredential = loadCreds controlCreds ++ [ "ui-proof:${runProof}/ui-proof" ];
|
||||
ReadWritePaths = [ stateRoot ];
|
||||
Restart = "on-failure";
|
||||
@@ -352,7 +358,10 @@ in
|
||||
};
|
||||
serviceConfig = hardening // {
|
||||
User = "caddy-fallback";
|
||||
Group = "ianitor";
|
||||
# The admin socket (and its runtime directory) belong to this group; "ianitor" for the
|
||||
# certificates and logs.
|
||||
Group = "ianitor-caddy-admin";
|
||||
SupplementaryGroups = [ "ianitor" ];
|
||||
ExecStart = "${cfg.caddyPackage}/bin/caddy run --config ${stateRoot}/caddy/caddy.json";
|
||||
LoadCredential = loadCreds cfg.credentials ++ [ "ui-proof:${runProof}/ui-proof" ];
|
||||
RuntimeDirectory = "caddy-fallback";
|
||||
@@ -367,6 +376,24 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# The deadline of a trial under Caddy, outside control (a hung control included): once a
|
||||
# second it reverts a trial past its deadline to the last good caddy.json. Runs with Caddy.
|
||||
systemd.services.ianitor-caddy-guard = {
|
||||
description = "Ianitor: deadline for changes tried on Caddy";
|
||||
partOf = [ "caddy-fallback.service" ];
|
||||
after = [ "caddy-fallback.service" ];
|
||||
wantedBy = [ "caddy-fallback.service" ];
|
||||
environment.IANITOR_LOG = "info";
|
||||
serviceConfig = hardening // {
|
||||
User = "ianitor-control";
|
||||
Group = "ianitor";
|
||||
ExecStart = "${pkg}/bin/ianitor-control caddy-guard --config ${controlToml}";
|
||||
ReadWritePaths = [ "${stateRoot}/control" ];
|
||||
Restart = "always";
|
||||
RestartSec = 1;
|
||||
};
|
||||
};
|
||||
|
||||
# At boot: start the engine the UI chose last (ROADMAP §3).
|
||||
systemd.services.ianitor-engine-select = {
|
||||
description = "Ianitor: start the chosen engine";
|
||||
|
||||
Reference in New Issue
Block a user