NixOS
There is a great overview with guides and additional resources to harden the base OS in the Wiki.
Basic Hardening
- Non-Root User: eg.
user = “1000:100”
- Advanced:
user = "nobody:nogroup"
- drop capabilities, restart, read the error if it crashes, add back the minimum
- run
podman inspect (check capabilities: NET_RAW, SYS_CHROOT, MKNOD, ...)
- add
capabilities.ALL = false; to everything
- Caddy, Vaultwarden, (maybe more) need
NET_BIND_SERVICE for port 80/443
- PostgreSQL: needs to chown data directories (
CHOWN, SETUID, SETGID, ...)
--security-opt=no-new-privileges
- read-only filesystem:
--read-only
- make sure these are
false, already default:
Health checks
- replace "is the process alive" with real HTTP check
- each runtime needs its own approach:
- Node: no curl, use Node's http module inline
- Python slim: no curl, use urllib
- Postgres: pg_isready just works
HTTP Headers
Secrets
Fix once
Reverse Proxy
Sources
NixOS
There is a great overview with guides and additional resources to harden the base OS in the Wiki.
Basic Hardening
user = “1000:100”user = "nobody:nogroup"podman inspect(check capabilities: NET_RAW, SYS_CHROOT, MKNOD, ...)capabilities.ALL = false;to everythingNET_BIND_SERVICEfor port 80/443CHOWN,SETUID,SETGID, ...)--security-opt=no-new-privileges--read-only--read-only-tmpfs=false(already default)false, already default:--privileged--ttyHealth checks
HTTP Headers
Secrets
Fix once
caddy-etc,stalwart-etc, ...Reverse Proxy
Sources