Skip to content

Environment variables

Every environment variable Nik reads, with its default and what it does.

Nik is configured with environment variables. The Compose file reads the .env beside it (made by deploy/init-env.sh) and passes each container what it uses; the secrets are files of NIK_SECRETS_DIR (Keys and secrets). A change is read when the containers are made again: docker compose up -d (or podman compose up -d).

In the tables, .env means the Compose file passes the variable from .env. Override means it does not: add it to the environment of that service in a Compose override file. Fixed means the Compose file sets it itself.

How to use them is in Configuration. Settings an administrator changes in the app (sign-in policy, backup schedule, bulk limits…) are not variables: they are kept in the database.

Backend

Read by the api container (and by automation, which runs the same image). Outside containers they can also come from backend/.env (backend/.env.example).

Database

Variable Default Compose Meaning
DATABASE_URL sqlite:///./nik.db override SQLAlchemy URL, used as it is. Production: postgresql+psycopg://nik:PASS@host/nik (the password URL-encoded).
DB_PASSWORD required .env / secret PostgreSQL password, shared by db, api and automation. Set when the database is first created; to change it later, change it in PostgreSQL first. When DATABASE_URL is not set, the backend builds the URL from it, escaping the password.
DB_USER, DB_HOST, DB_PORT, DB_NAME nik, localhost, 5432, nik DB_HOST fixed (db) The other parts of that URL.
DB_POOL_SIZE, DB_MAX_OVERFLOW, DB_POOL_RECYCLE 5, 10, 1800 override Connections kept per backend process, extra ones under load, their lifetime in seconds.
DB_STATEMENT_TIMEOUT_MS 30000 override A query running longer is cancelled (PostgreSQL only).
RUN_CREATE_ALL true (false in the image) override Create the tables at start without Alembic: for development on SQLite only.

Keys and secrets

Every secret can also be given as a file: see <NAME>_FILE.

Variable Default Compose Meaning
SECRET_KEY dev-insecure-change-me .env / secret Encrypts the secrets stored in the database (credentials of instances, second factors, the backup passphrase, TLS key logs). The container refuses the default and any value under 16 characters. Changed with deploy/secrets.sh rotate secret-key.
SECRET_KEY_PREVIOUS — .env / secret Earlier values of SECRET_KEY, separated by commas or lines, kept while it changes. Set and removed by deploy/secrets.sh.
STORE_KEY dev-insecure-store-key-change-me .env / secret Seals every file of the store on disk. In no database and no backup. Given to api only. The container refuses the default and any value under 32 characters; without it the server stays up and says so.
STORE_KEY_PREVIOUS — .env / secret Earlier store keys, kept while the store key changes.
AUDIT_KEY made by init-env.sh on a new install; otherwise derived from SECRET_KEY .env / secret Signs every entry of the audit log. Given to api and automation only. hex:… for a key written as bytes. Set or changed with deploy/secrets.sh rotate audit-key.
AUDIT_KEY_PREVIOUS — .env / secret Earlier audit keys, separated by commas or lines, so the entries they signed can still be checked.
<NAME>_FILE — fixed For every secret (SECRET_KEY, STORE_KEY, their _PREVIOUS, AUDIT_KEY, its _PREVIOUS, DB_PASSWORD, the worker tokens, METRICS_TOKEN): a file read in place of the variable. An empty file counts as none. A secret given both ways, or in a file that cannot be read, stops the server with a sentence naming it.
STORE_SEAL_MBPS 40 .env How fast a store from before 6.8 is sealed, in MB read a second (0: as fast as the disk).
METRICS_TOKEN — .env / secret A bearer token /api/metrics accepts beside the scrape token made on the Health page. With neither, nobody reads the metrics.
NIK_NO_STORE_KEY, NIK_STORE_API_URL — fixed (automation) The container holds neither the store nor its key (1) and asks the backend at this address for the files a step needs.
NIK_SKIP_MIGRATIONS — fixed (automation) 1: leave migrations and the store-key check to the backend. Never set it for the backend.

Sign-in, sessions and the client's address

Variable Default Compose Meaning
COOKIE_SECURE true .env Secure flag on the session cookie. Set false only for plain-HTTP local development.
SESSION_TTL_HOURS 12 .env The longest a session lasts, until an admin sets another in Sign-in and sessions (what is set there wins).
TRUSTED_PROXIES empty (web in Compose) .env Who X-Forwarded-For is believed from: host names, addresses or networks, comma-separated. From anybody else the header is ignored.
FORWARDED_ALLOW_IPS 127.0.0.1 (empty in Compose) fixed gunicorn's own list of trusted proxies. Leave it empty: the backend decides itself (TRUSTED_PROXIES). Never *.
RATE_LIMIT_DEFAULT 600/minute override Requests each client address may make (slowapi notation). Signing in has its own limit, 10 a minute.
RATE_LIMIT_STORAGE_URI memory:// override Where rate-limit counters are kept; a Redis URL shares them between processes and hosts.

Files and size limits

Variable Default Compose Meaning
SAMPLE_STORE ./samples fixed (/app/samples) Directory of the store of files (samples, e-mails, captures, mailboxes), each sealed under STORE_KEY.
SAMPLE_MAX_MB 100 .env Largest sample or e-mail upload, in MB.
ARTIFACT_MAX_MB 500 .env Largest evidence file the server parses (POST /api/incidents/{id}/upload); larger is refused with 413.
PCAP_MAX_MB 500 .env Largest packet capture, in MB.
MAILBOX_MAX_MB 2048 .env Largest mailbox (mbox, or a zip or tar of a Maildir), in MB.
PST_MAX_MB 4096 .env Largest Outlook PST, in MB. Converted by docview on its pst-work volume, which needs about 2.5 times the PST free. The shipped nginx lets 4200 MB through for mailboxes: to raise this or MAILBOX_MAX_MB beyond it, raise client_max_body_size of the mailbox location in frontend/nginx/nginx.conf too.
YARA_RULES app/malware/yara override Directory of the built-in YARA rules (*.yar). Rules added by admins live in the database.

Workers

Variable Default Compose Meaning
ANALYZER_URL, ANALYZER_TOKEN — URL fixed, token .env / secret The rizin worker and its shared secret. Without them the Code view says "not configured".
ANALYZER_TIMEOUT 600 .env Seconds rizin may spend on one sample.
CAPA_URL, CAPA_TOKEN — URL fixed, token .env / secret The capa worker and its secret. Without them the Capabilities view says "not configured".
CAPA_TIMEOUT 1800 .env Seconds capa may spend on one sample.
DOCVIEW_URL, DOCVIEW_TOKEN — URL fixed, token .env / secret The document viewer (previews, PST). Without them Preview is disabled.
BROWSER_URL, BROWSER_TOKEN — URL fixed, token .env / secret The isolated browser. Without them HTML attachments and links do not open.
PCAP_URL, PCAP_TOKEN — URL fixed, token .env / secret The packet capture worker. Without them captures are stored, not analysed.
SANDBOX_URL, SANDBOX_TOKEN — URL fixed, token .env / secret The script sandbox. Without it a script step fails, saying the sandbox is not configured.
SANDBOX_TIMEOUT, SANDBOX_MAX_TIMEOUT 10, 60 .env How long a script may run, in seconds: by default, and at most (600 at the very most).

Background work and automation

Variable Default Compose Meaning
AUTOMATION_WORKER container .env Where playbooks run: container (the automation service), inline (a thread of the backend, for an install without that container) or off (no event recorded, nothing runs).
AUTOMATION_CONCURRENCY 4 .env Playbook steps run side by side (1 to 32).
AUTOMATION_MAX_ACTIVE_RUNS 200 .env Runs in progress at once on the server; more are refused.
AUTOMATION_RUNS_KEPT 500 .env Finished runs each playbook keeps (at least 10).
AUTOMATION_HTTPS_PROXY, AUTOMATION_NO_PROXY empty .env A proxy for what playbooks send out, and the hosts reached without it.
ENRICHMENT_WORKER true override The thread of automatic threat-intelligence look-ups and bulk checks. false turns it off (Check now still works).
API_BACKGROUND true override The backend's own threads: the watch of the workers and the address scans playbooks ask for. false turns both off.

Content packs

Variable Default Compose Meaning
NIK_PACKS_CATALOGUE the release packs of Nik's repository .env Address (https) of the catalogue index, until an admin sets another in the app. Empty: no catalogue, packs come as files.
NIK_PACKS_DIR empty .env A folder inside the api container whose packs are installed at start when missing or older. Mount it read-only with an override. Not checked against a signature.

Backups, recovery and the standby

Variable Default Compose Meaning
NIK_BACKUP_DIR the volume backups .env A host directory for the backups, in place of the volume: another disk than the data. Inside the containers it is /app/backups (BACKUP_DIR, which an install without containers sets).
NIK_UPGRADE_REHEARSAL true .env false skips the rehearsal of migrations on a copy (never the snapshot), for a database too large to copy at every upgrade.
NIK_WAL_ARCHIVE on .env (db) The archive of the PostgreSQL log. off: no recovery to a moment, no standby.
NIK_ARCHIVE_TIMEOUT 300 .env Seconds after which PostgreSQL closes a log segment while something is written: the most lost when the host dies. Counted as at least 10.
NIK_WAL_ARCHIVE_DIR the volume wal-archive .env A host directory for the archive and the base backups (in clear). Inside the backend it is /app/wal-archive (WAL_ARCHIVE_DIR).
NIK_STANDBY_INBOX empty .env On a standby: the directory the first host sends to. Written by deploy/standby.sh init and rejoin; do not set by hand.
NIK_SERVER_NAME TLS_HOSTNAME .env What this server calls itself to the other host of a pair (120 characters at most). A name set on the Backup page wins; with neither, the machine name.

Operations

Variable Default Compose Meaning
LOG_LEVEL INFO override Verbosity of the backend log.
WEB_CONCURRENCY 2 (in the image) override Backend processes (gunicorn).
API_STOP_GRACE 20 override Seconds the backend gives requests in flight when asked to stop. Must stay under the stop_grace_period of api (40 s).
NIK_WEB_TLS web:443 override Where the backend reads the web certificate for the Health page. Empty when there is none; the host and port of your own proxy on a manual install.
PROMETHEUS_MULTIPROC_DIR /tmp/nik-metrics (in the image) override Where the backend processes add up their request counts, so /api/metrics gives the same totals whichever answers.

Compose

Read by docker-compose.yml itself, from .env. The variables marked required have no default: Compose stops when one is not named at all (its line may be empty when the value is in a file of NIK_SECRETS_DIR).

Variable Default Meaning
NIK_SECRETS_DIR — (./secrets on a new install) The directory of the secrets as files, each mounted into the containers that use it. Unset on a server that keeps its secrets in .env.
DB_PASSWORD, SECRET_KEY, ANALYZER_TOKEN, CAPA_TOKEN, DOCVIEW_TOKEN, BROWSER_TOKEN, PCAP_TOKEN, SANDBOX_TOKEN required The secrets (see above). Each worker token is different, long and random.
WEB_TLS_PORT 8443 Host port of the app (HTTPS).
WEB_PORT 8080 Host port for plain HTTP: only redirects to HTTPS.
TLS_HOSTNAME localhost Name in the self-signed certificate (CN and SAN): what users type.
PCAP_MEMORY_FILE_MB 64 A capture this size or smaller stays in the memory of pcap; a larger one goes to its pcap-work volume while open.

Limits of the containers

Variable Default Container
API_MEMORY, API_CPUS 4g, 4 api (parses the evidence)
WEB_MEMORY 512m web
AUTOMATION_MEMORY, AUTOMATION_CPUS 1g, 2 automation
SANDBOX_MEMORY, SANDBOX_CPUS 512m, 1 sandbox
RECOVERY_MEMORY, RECOVERY_CPUS 1g, 2 recovery
ANALYZER_MEMORY, ANALYZER_CPUS 4g, 2 analyzer
CAPA_MEMORY, CAPA_CPUS 4g, 2 capa
DOCVIEW_MEMORY, DOCVIEW_CPUS 2g, 1 docview
BROWSER_MEMORY, BROWSER_CPUS 2g, 2 browser
PCAP_MEMORY, PCAP_CPUS 4g, 2 pcap (sharkd keeps an open capture in memory: a few times its size)

Container logs are rotated at 20 MB.

Tuning and worker variables

Rarely needed; the defaults suit a single server. Read by the worker containers (and TLS_SELFSIGNED_DAYS by web). The ones marked .env are passed by the Compose file; the others need an override.

Variable Default Meaning
ANALYZER_DECOMPILE_SECONDS 300 (.env) Part of the analysis spent decompiling functions up front; the rest are decompiled when opened.
ANALYZER_MAX_FUNCTIONS 20000 (.env) Safety cap on functions listed per sample.
ANALYZER_WARM_SESSIONS, ANALYZER_WARM_IDLE 1, 600 (.env) Analysed sessions kept open so decompiling on demand takes seconds (0 disables; about 1 GB each on a large binary), and how long an unused one stays.
ANALYZER_MAX_JOBS, CAPA_MAX_JOBS, DOCVIEW_MAX_JOBS, PCAP_MAX_JOBS, SANDBOX_MAX_JOBS 2, 1, 2, 2, 4 Jobs each worker runs at once; more are answered "busy". ANALYZER_MAX_JOBS is passed from .env.
ANALYZER_FILES_MB, CAPA_FILES_MB, PCAP_FILES_MB 1024, 1024, 16384 MB of sent files each worker holds; a single larger file is refused.
DOCVIEW_TIMEOUT, DOCVIEW_MAX_PAGES, DOCVIEW_MAX_MB 90, 20, 50 Seconds a preview may take, pages rendered, largest document in MB.
DOCVIEW_PST_TIMEOUT 3600 Seconds for one PST conversion. The backend waits 3900 seconds for it.
DOCVIEW_PST_TMP_MAX_MB 500 Largest PST converted in memory when the worker has no writable pst-work volume.
BROWSER_MAX_SESSIONS 3 (.env) Isolated browser sessions open at once.
BROWSER_IDLE, BROWSER_LIFETIME 300, 1800 Seconds a session lasts without an action, and in all.
PCAP_TIMEOUT, PCAP_RPC_TIMEOUT, PCAP_MAX_SESSIONS, PCAP_SESSION_IDLE 900, 300, 2, 900 Seconds to summarise a capture and to answer one question; captures open at once; idle time before one closes.
SANDBOX_MEMORY_MB 256 (.env) Memory one script may use, in MB.
ANALYZER_STOP_GRACE, CAPA_STOP_GRACE, DOCVIEW_STOP_GRACE, PCAP_STOP_GRACE 20 each Seconds a worker gives its jobs when asked to stop. Must stay under the service's stop_grace_period (30 s).
TLS_SELFSIGNED_DAYS 825 Validity of the self-signed certificate. Read only when the certificate is made.

Read by the scripts

Read from the environment of the shell that runs a script of deploy/, never from .env.

Variable Default Read by Meaning
NIK_DIR the script's ../ every script The repository root with docker-compose.yml.
ENGINE, COMPOSE podman if installed, else docker; $ENGINE compose every script The container engine and compose command.
NIK_BACKUP_PASSPHRASE, NIK_BACKUP_PASSPHRASE_FILE — restore.sh, rollback.sh, standby.sh The backup passphrase (or a file holding it), for a run nobody attends. Never on the command line.
NIK_TRANSFER_PASSPHRASE — standby.sh secrets export/import The passphrase of the file of keys (12 characters or more). Never in .env.
NIK_RECOVERY_WAIT 3600 restore.sh --to, standby.sh Seconds a replay of the log is waited for.
NIK_BACKUP_WAIT 21600 backup.sh Seconds to wait for the backup it asked for.
NIK_ROTATE_WAIT 21600 secrets.sh Seconds to wait for a change of key to be verified.
NIK_EXISTING_INSTALL detected init-env.sh 1 says Nik already ran here (keeps the old database password and key), 0 that it is new, when the script cannot see the database volume.
NIK_SECRETS files init-env.sh env writes the secrets into .env instead of files.
NIK_AUDIT_KEYS — verifier.py The audit keys, to check signatures (or --keys FILE).