nixos: monitoring as native services

Every host runs node_exporter, cAdvisor (now against Podman), Alloy and
the security-metrics script, on its private address. Each service
declares its own expected ports, users and privileged containers next
to its definition, so the security baseline follows the config instead
of a separate inventory list.

On ops: Prometheus, Loki, Grafana, the blackbox prober and the Postgres
exporter, with the same scrape jobs, probes, retention, dashboards and
33 alert rules. Two rules matched container-era names and now match the
native ones: Forgejo's log is unit forgejo.service, Grafana's route is
grafana@file.

Grafana keeps its default secret_key on production, because its
database was written with it; rotating it is a separate step.

Prometheus, Grafana and Alloy come from nixos-unstable: their data is
from newer versions than 26.05 ships.

LLMNR and mDNS are off: the baseline flagged them as public listeners.

Tried on the rehearsal pair: all 28 scrape targets up, logs from both
hosts in Loki, Grafana WireGuard-only, no unexpected port, user or
container on either host.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 04:48:56 +04:00
commit cbf14b4b99
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
7 changed files with 30417 additions and 104 deletions

View file

@ -17,4 +17,5 @@
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
asxpio.security.ports = [ "tcp/80/nginx" ];
}

View file

@ -18,6 +18,7 @@
networking.hostName = lib.mkDefault "asxpio-services";
networking.domain = "asxp.io";
asxpio.privateIPv4 = "10.10.0.20";
system.stateVersion = "26.05";
systemd.network.networks."10-public".address = [ "2a01:4f9:c013:8269::1/64" ];

View file

@ -29,5 +29,10 @@
];
};
networking.firewall.allowedTCPPorts = [ 25565 ];
asxpio.security.ports = [
"tcp/25565/java"
"tcp/19132/java" # Geyser's signalling
"udp/19132/java" # Bedrock
];
networking.firewall.allowedUDPPorts = [ 19132 ];
}

View file

@ -72,6 +72,10 @@ in
token: ${config.sops.placeholder."runner/interop_token"}
'';
# The job cache server listens on a random port
asxpio.security.ports = [ "tcp/*/.forgejo-runner" ];
asxpio.security.containers."FORGEJO-ACTIONS-TASK-.*" = [ "docker-sock" ]; # docker_host: automount
services.gitea-actions-runner = {
package = pkgs.forgejo-runner;
instances.asxpio = {

View file

@ -10,6 +10,7 @@
# are in the config file; the module's flags do not reach the server
};
asxpio.waitForData = [ "sillytavern" ];
asxpio.security.ports = [ "tcp/8000/MainThread" ];
systemd.services.sillytavern = {
after = [ "wireguard-${config.asxpio.wireguard.interface}.service" ];
wants = [ "wireguard-${config.asxpio.wireguard.interface}.service" ];

View file

@ -82,6 +82,19 @@ in
"podman-xmpp-tackygram"
];
# Published ports belong to rootful Podman's port forwarder
asxpio.security.ports = map (p: "${p}/conmon") [
"tcp/5222-5223"
"tcp/5269"
"tcp/5443"
"tcp/8448"
"tcp/3478"
"udp/3478"
"tcp/7777"
"udp/49160-49199"
"udp/50000-50099"
];
networking.firewall.allowedTCPPorts = [
5222
5223

View file

@ -10,4 +10,8 @@
};
systemd.services.xray.restartTriggers = [ config.sops.secrets."xray/config".sopsFile ];
networking.firewall.allowedTCPPorts = [ 443 ];
asxpio.security.ports = [
"tcp/443/.xray-wrapped"
"udp/*/.xray-wrapped" # outbound relay sockets
];
}