/nhi to it and TRUSTIVAN signs people in. Standalone, it brings its own TLS edge and its own password sign-in.
What you run
The browser only ever talks to the console’s origin. The console forwards
/nhi/api/* to the API’s /api/*, so the session cookie stays first-party and the API needs no public address. That is why these docs spell one route two ways: /api/v1/findings is the route as the API serves it, and /nhi/api/v1/findings is the same route as a browser or a script reaches it through the console’s origin. internal and data are internal Docker networks: the edge cannot reach the API or the database, and the console cannot reach the database.
The api and web containers run with a read-only root filesystem, no-new-privileges, and memory, CPU and process limits. The defaults suit a host with 4 vCPU and 8 GB of memory; the variables that change them are in the configuration reference.
Three database connections
NHI Security uses three PostgreSQL roles, and the split is what makes organization isolation enforceable:Choose a sign-in mode
AUTH_MODE decides who signs people in. Set the same value on both the api and the web service: the API needs it to authenticate requests, and the console needs it to know where to send someone with no session.
In
trustivan mode a state-changing request must carry an X-CSRF-Token header equal to the trustivan_csrf cookie, and must come from an origin listed in CORS_ALLOWED_ORIGINS. If TRUSTIVAN cannot be reached, errors or times out, the request is refused. An earlier answer is never reused in its place. Overview describes what the user experiences.
Run it beside TRUSTIVAN AppSec
This is the shapehttps://app.trustivan.com/nhi describes: one origin, one session, two consoles. It uses the same Compose file as the standalone shape with an overlay, infra/docker/nhi.override.yml, that changes three things: the api and web services join the Docker network the AppSec containers share (trustivan-public, which must already exist), both are put into trustivan mode, and scheduled discovery is turned off.
1
Point the dashboard at the NHI Security console
The AppSec dashboard proxies
/nhi and everything under it to the address in NHI_WEB_URL. Left empty (the default), the dashboard is built without NHI Security: it hides the NHI Security switch and /nhi says NHI Security is not enabled on this deployment. The value is read when the dashboard is built, so changing it means rebuilding the dashboard image, not restarting it.2
Write the environment file
Copy Set
nhi/deploy/.env.production.example, fill it in as described in the configuration reference, and add the overlay’s own variables:PUBLIC_ORIGIN to the address people open the dashboard at. The API accepts state-changing requests only from that origin. NHI_WEB_URL in the previous step must name the console by NHI_WEB_ALIAS and port 3100.3
Build the images from the repository root
Both Dockerfiles (
nhi/deploy/docker/api.Dockerfile, nhi/deploy/docker/web.Dockerfile) expect the repository root as their build context, which is how the Compose file builds them.4
Start four services by name
up -d also starts caddy, which publishes ports 80 and 443 and collides with whatever already terminates TLS for the dashboard.If you run two NHI Security stacks on one Docker network, never address either by its Compose service name. Both register
api and web, and Docker’s DNS returns either one. That is what the two aliases are for.docker-compose.yml already includes the four NHI Security services in trustivan mode (make docker-up), with the API on 127.0.0.1:4000 and the console on 127.0.0.1:3100. See Install with Docker Compose for the AppSec side.
Run it standalone
Standalone, NHI Security serveshttps://<your domain>/nhi from its own Caddy edge and signs people in itself.
1
Prepare the host
Install Docker with the Compose plugin. Point your domain at the host’s public address before the first start: Caddy proves control of the domain to the certificate authority on ports
80 and 443, and a domain that does not resolve yet fails issuance.2
Write the environment file
PUBLIC_DOMAIN, PUBLIC_ORIGIN, TLS_EMAIL, the three database passwords and CREDENTIAL_ENCRYPTION_KEY. APP_ENV must be production or staging. Every variable is described in the configuration reference.3
Deploy
deploy/scripts/deploy.sh checks the environment file, builds both images from the working tree, starts PostgreSQL, applies migrations, starts the API, then the console, then Caddy, and waits until GET /api/v1/readyz reports ready. If migrations fail, nothing is restarted and the running version is untouched. --no-build starts images that are already built or pulled.4
Create the first platform operator
Kubernetes
nhi/deploy/kubernetes/ holds Kustomize manifests for the same topology: a base (namespace, API, console, Caddy, a migration Job and default-deny NetworkPolicies), an in-cluster PostgreSQL component with a backup CronJob, and local and production overlays. make k8s-validate renders every overlay offline and holds it to the deployment’s invariants, and make k8s-deploy OVERLAY=production validates, applies, waits for migrations and verifies from inside the Pods.
Two constraints are enforced by that validation rather than left to convention: the production overlay must name both images by digest (a tag or :latest is refused), and the API must run exactly one replica. There is no Helm chart, and no Kubernetes equivalent of restore.sh.
Health checks
Both routes are unauthenticated, so an orchestrator can call them.Back up and restore
The scripts innhi/deploy/scripts/ read deploy/.env.production themselves. Each has a make target.
Three things to plan for:
- Nothing schedules any of this. No cron entry or timer ships. Until you install one, no backup is taken and nothing notices.
- A backup is plaintext unless you set
BACKUP_PUBLIC_KEY. It is an age recipient (a public key). When set,backup.shencrypts the dump, checks the result and removes the plaintext; the host then holds nothing that can read its own backups. When unset, the script says so on every run. Restoring an encrypted dump needsBACKUP_IDENTITY_FILE. - A dump does not contain
CREDENTIAL_ENCRYPTION_KEY. Stored connector credentials are in the dump as ciphertext. Back the key up separately, somewhere the database backup is not. A restore onto a host with a different key completes, and every stored credential in it is unreadable.
What is not proven
- No standalone deployment has run on a public host. Certificate issuance, the HSTS edge and
deploy.shon a remote machine are untested. - The Kubernetes path has run against one local, single-node k3s cluster and no other.
deploy.shbuilds from the working tree. Running a published image through it is a manual procedure: setIMAGE_APIandIMAGE_WEB, pull, then run with--no-build. That procedure has not been exercised.postgres:16-alpineandcaddy:2-alpineare not pinned in the Compose file, anddeploy.shnever pulls them.- Remediation execution cannot be switched on from the environment file.
docker-compose.prod.ymldoes not passREMEDIATION_EXECUTION_ENABLEDto the API, so it stays off unless you edit the Compose file as well. See Remediation. - The API runs as one replica. The rate limiter counts per process, so a second replica would double every client’s ceiling, and scheduled discovery runs inside the same process. See Discovery and synchronization.
Next steps
Configuration reference
Every environment variable, its default, and what refuses to start.
Platform operators
Create the first operator and provision an organization.
Administration
Users, teams, roles and organization settings.
Limitations
What NHI Security does not do today.