How configuration is read
The API validates its whole environment once, at startup, and refuses to start if any value is invalid. The error names the failing variable and the reason and never prints the value, so a misconfiguration cannot leak a secret into a log. With Docker Compose you set most variables innhi/deploy/.env.production, copied from .env.production.example. Compose reads that file with --env-file, which does not expand shell syntax: write literal values, with no $(...), no ${OTHER} and no quotes unless the quotes are part of the value. The Compose file composes some API variables for you (the three database URLs, CORS_ALLOWED_ORIGINS, API_HOST, API_PORT), so in that shape you set the inputs listed under Compose-only variables instead.
Combinations that refuse to start
Deployment identity and network
Trusted proxies
Left empty, the API records the address that opened the socket and ignores forwarding headers entirely, which is correct when clients reach the API directly. Behind the shipped console and edge, every request would then be attributed to the console’s container. SetTRUSTED_PROXIES=private_ranges in that topology, which is what the production Compose file defaults to.
The value is load-bearing for three things: the sourceIp on audit records, the runtime gate’s source_address_unrecognised rule (which has no address to compare without it), and which bucket a caller’s rate limit is counted in. Widen it only to networks you operate. Anything it covers can write any source address it likes into your audit trail.
Sign-in
Deploy NHI Security compares the two modes.
Database
The running API never needs the owner credential. The production Compose file gives the
api service the application login in DATABASE_URL as well, so that no code path in it can connect as the owner.
Encryption keys and secret storage
Choosing a secret store
databasestores material encrypted, versioned and rotatable, and a new credential needs no restart. Entries are created through the API. See Credentials and rotation.environmentreads onlyCONNECTOR_SECRETS. It cannot version or rotate anything, and changing an entry means restarting the API.bothreads the database first and falls back toCONNECTOR_SECRETS. Registering a reference through the API is refused when configuration already defines that name, so the two stores can never disagree about one reference.
{"aws-production":{}}, so that a mistyped reference fails loudly instead of resolving to “no credentials needed”.
Connector endpoint suffixes
Providers with a fixed home, such as AWS and GitHub, reach only hosts fixed in code. Self-hosted providers do not have one, so this setting is how you permit a host such as your own Vault or GitLab. The decision deliberately sits with the deployment and never with an organization filling in a connector form. Whatever you list, private, loopback, link-local and cloud metadata addresses stay refused: the setting can permit a public host, never an internal one. Connectors lists which providers it applies to.Rotating the encryption key
1
Generate a new key and give it a new id
Set
CREDENTIAL_ENCRYPTION_KEY to the new key and CREDENTIAL_ENCRYPTION_KEY_ID to a new name, such as k2.2
Keep the old key readable
Add the previous key to
CREDENTIAL_ENCRYPTION_RETIRED_KEYS under its old id: {"k1":"<the previous key>"}. Two keys must never share an id.3
Restart the API
New records are written under
k2. Existing records still open under k1.CREDENTIAL_ENCRYPTION_RETIRED_KEYS, and a backup taken before the rotation needs that key configured before anything in it can be read.
Scheduled discovery
Turn the scheduler on after your connectors are registered and their first manual synchronization has succeeded, so the schedule starts against something known to work. The overlay that runs NHI Security beside AppSec sets it to
false. Discovery and synchronization describes what a scheduled run does.
Rate limits and logging
Four routes carry a tighter limit of their own that these variables do not change: sign-in, password change and invitation acceptance allow 10 requests a minute per address, and operator sign-in allows 5. Counters are held in each API process, which is one reason the API runs as a single replica.
The console’s own server-side reads are counted against the person who caused them, not against the console. They forward
X-Forwarded-For and X-Real-IP the way its /api proxy does, which the API believes only when TRUSTED_PROXIES covers the console. With every hop trusted and no client address recorded, those reads fall back to the console’s address again. The console also keeps the brand it read for 30 seconds and goes on showing the last brand it read successfully when the API answers 429, 5xx or not at all, so a throttled brand read does not replace the console with an error page. A console that has never read a brand still shows none.
Remediation
The production Compose file does not pass this variable to the API, so setting it in
.env.production alone changes nothing. Enabling execution means editing the Compose file too. See Remediation.
Demonstration data
Console
The console reads four variables of its own.
The console’s base path,
/nhi, is fixed in the build and is the same in both sign-in modes.
Compose-only variables
These are read bynhi/deploy/docker-compose.prod.yml, not by the API.
The overlay for running beside AppSec (
infra/docker/nhi.override.yml) adds NHI_IDP_ORIGIN (required, becomes TRUSTIVAN_API_ORIGIN), NHI_API_ALIAS and NHI_WEB_ALIAS (required, unique per stack) and NHI_DOCS_URL (optional, becomes DOCS_URL). The AppSec dashboard reads NHI_WEB_URL when it is built; empty (the default) builds it without NHI Security (make dev sets http://localhost:3100).
Resource limits
Each container has a ceiling so one runaway service cannot take the host down. Size them againstdocker stats under real load.
Raise PostgreSQL’s limit before any other. A limit below its
shared_buffers plus per-connection memory ends in an out-of-memory kill under load.
Backup scripts
backup.sh, restore.sh and restore-rehearsal.sh load deploy/.env.production, so these can be set there.
check-backup-freshness.sh and check-host-resources.sh do not load that file. Set their variables in the environment of whatever runs them: BACKUP_MAX_AGE_HOURS (26), BACKUP_CHECK_MIN_FREE_MB (4096), DISK_WARN_PERCENT (80), DISK_FAIL_PERCENT (90) and MEMORY_WARN_PERCENT (90).
Next steps
Deploy NHI Security
The services, the two shapes, and what has not been proven.
Connectors
What each connector needs registered under its credentials reference.