Reference
Environment variables
Most behaviour is configured in the admin panel. Environment variables only cover what the containers need at start-up, such as ports, secrets and the database connection. This page lists the variables in env.example, in docker-compose.yml and those the API reads.
How values reach the containers
Docker Compose reads the .env file in the same directory as docker-compose.yml and fills in the ${VARIABLE} placeholders. A value in .env therefore reaches a container only if docker-compose.yml references that variable.
- Variables marked compose in the "Passed" column can simply be set in
.env. - Variables marked add yourself are not in the stock
docker-compose.yml; add a line to theenvironment:section of theapiservice.
After changing a value, recreate the containers for it to take effect.
docker compose up -dRequired
| Variable | Default | Passed | Description |
|---|---|---|---|
DB_PASSWORD | none | compose | PostgreSQL (TimescaleDB) password. Generate one with openssl rand -base64 24. |
JWT_SECRET | the placeholder in compose | compose | Application secret. Replace it with a random value from openssl rand -hex 32. |
General
| Variable | Default | Passed | Description |
|---|---|---|---|
TZ | UTC | compose | Time zone of all containers. Log times, schedules and the hour of the daily notification summary follow it. env.example sets Asia/Seoul. |
DB_USER | postgres | compose | Database user |
DB_NAME | nginx_proxy_guard | compose | Database name |
DOCKER_API_VERSION | auto-detected | compose | Set only if auto-detection fails. Synology DSM typically uses 1.41 or 1.43. |
Ports and network
| Variable | Default | Passed | Description |
|---|---|---|---|
UI_PORT | 81 | compose | Host port of the admin panel (HTTPS) |
NGINX_HTTP_PORT | 80 | compose | HTTP port nginx listens on. nginx uses the host network, so this is the host port. Change it when another service, such as Synology Web Station, holds port 80. |
NGINX_HTTPS_PORT | 443 | compose | HTTPS port nginx listens on |
API_HOST_PORT | 9080 | compose | Loopback port nginx uses to reach the API (open on 127.0.0.1 only). Must not collide with NGINX_HTTP_PORT. |
API_HOST | 127.0.0.1: + API_HOST_PORT | compose | API address written into the nginx configuration. Normally left empty. |
DNS_RESOLVER | 127.0.0.53 8.8.8.8 | add yourself | DNS servers nginx uses for name resolution (space separated). It is commented in env.example, but the stock compose file does not pass it. |
API rate limits and client IP
| Variable | Default | Passed | Description |
|---|---|---|---|
API_RATE_LIMIT_PER_MINUTE | 600 | compose | Requests per minute per IP to the admin panel API. The panel spends this budget itself (the host list probes each row's upstream and several screens poll on timers). Raise it if a large installation sees 429s in the panel. 0 turns it off. |
AUTH_RATE_LIMIT_PER_MINUTE | 100 | compose | A separate per-IP, per-minute budget for the sign-in endpoints, so panel traffic cannot lock you out of signing in. 0 turns it off. |
TRUSTED_PROXY_CIDR | unset | compose | Addresses the API trusts as proxy hops when walking X-Forwarded-For (comma-separated CIDRs). Unset trusts all loopback, link-local and private ranges. When set, only loopback and the listed ranges are trusted, which stops a device on your LAN from spoofing its address. Login lockout, rate-limit keys, API token IP allow lists and audit logs follow it. |
RATE_LIMIT_RPS | 100 | add yourself | A per-IP requests-per-second limit on every API request (counted in API memory) |
RATE_LIMIT_ENABLED | on | add yourself | false turns the per-second limit above off. |
For example, to trust only the Docker bridge range and the host's own address:
TRUSTED_PROXY_CIDR=172.16.0.0/12,192.0.2.10/32This variable is for the admin panel API. The real IP of visitors to your proxy hosts is configured in Settings → Trusted Proxies (Running behind Cloudflare).
Cache (Valkey)
| Variable | Default | Passed | Description |
|---|---|---|---|
REDIS_URL | redis://valkey:6379/0 | compose | Valkey (Redis-compatible) address the API uses for caching and the per-minute rate-limit counters. Empty runs without Valkey, keeping them in the API process's memory. |
NPG_LOCAL_CACHE_MAX_MB | automatic | compose | Upper bound (MiB) of the in-memory cache used while Valkey is absent or not yet connected. Unset uses 1/32 of the API's memory limit (the smallest of the cgroup limit, GOMEMLIMIT and host RAM), kept within 4 to 64 MiB. 0 turns it off. |
To run without Valkey, put REDIS_URL= (empty) in .env and also remove the valkey entry under depends_on of the api service in docker-compose.yml; otherwise Compose refuses to start. What changes without Valkey is described in Architecture.
Domain entries
| Variable | Default | Passed | Description |
|---|---|---|---|
NPG_DNS_ENTRIES_DISABLED | unset | compose | 1 keeps every domain entry closed regardless of the settings (no client is allowed through a domain name). An emergency switch; each start with it set is recorded in the audit log. |
NPG_DNS_ENTRIES_INTERVAL | unset (the settings decide) | compose | Check interval for domain entries, 5 seconds to 1 hour (for example 60s). Takes precedence over the settings. Values under 30 seconds are for testing. |
Disk alerts
The stock docker-compose.yml contains the first five of these as comments. Uncomment them and set a value to use them.
| Variable | Default | Passed | Description |
|---|---|---|---|
NPG_DB_CONTAINER | auto-discovered | compose (commented) | Name of the database container. Set it only when the dashboard says the database disk could not be measured. |
NPG_DISK_WARN_PERCENT | 85 | compose (commented) | Warning line for Disk space running low (%) |
NPG_DISK_CRITICAL_PERCENT | 90 | compose (commented) | Line for Disk space critical (%). When the database disk passes it, older log chunks are compressed early (no data is deleted). |
NPG_DISK_RECOVER_PERCENT | 80 | compose (commented) | Line for Disk space back to normal (%) |
NPG_DISK_EMERGENCY_COMPRESS | on | compose (commented) | Emergency compression at the critical line: on, off or dryrun (only reports how much could be compressed) |
NPG_DISK_GUARD_DISABLED | unset | add yourself | 1 turns off disk alerts, the dashboard storage warning and emergency compression. |
NPG_DISK_GUARD_INTERVAL | 1m | add yourself | How often disks are measured (at least 15 seconds) |
NPG_DISK_ALERT_COOLDOWN | 6h | add yourself | How long after a recovery a new "running low" alert is held back |
The three lines must satisfy 0 < recovery < warning < critical < 100; otherwise the defaults are used.
Schedulers and others
| Variable | Default | Passed | Description |
|---|---|---|---|
NPG_DDNS_INTERVAL | the settings value (5 minutes by default) | add yourself | How often DDNS checks the public IP (for example 5m). Takes precedence over the settings. |
NPG_DDNS_DISABLED | unset | add yourself | 1 or true turns the DDNS scheduler off. |
NPG_CONTAINER_RECONCILE_INTERVAL | 30s | add yourself | How often the container IP of hosts that target a container is re-checked |
NPG_CONTAINER_RECONCILE_DISABLED | unset | add yourself | 1 or true turns that check off. |
NPG_DB_MAX_OPEN | 80 | add yourself | Maximum database connections of the API |
NPG_DB_MAX_IDLE | 20 | add yourself | Idle connections. Reduced to NPG_DB_MAX_OPEN if larger. |
NPG_RAW_LOG_ARCHIVE_DIR | /archive | add yourself | Path of the raw log archive directory inside the container |
ENABLE_DOCKER_LOGS | on | add yourself | false does not start the container log (system log) collector. |
LOG_COLLECTION | true | add yourself | false does not start the nginx log collector. The log screens, dashboard statistics and fail2ban depend on it, so do not turn it off in production. |
CORS_ALLOWED_ORIGINS | development addresses | add yourself | Allowed CORS origins for the API (comma separated). The admin panel calls the API from the same origin, so this is normally not needed. |
Values fixed in the compose file
These values are written directly in docker-compose.yml and are normally left alone.
| Variable | Value | Description |
|---|---|---|
PORT | 8080 | Port the API listens on inside its container |
DATABASE_URL | built from DB_USER, DB_PASSWORD, DB_NAME | Database connection string |
ENVIRONMENT | production | development or test turns the per-minute API rate limit off, and test also turns off the login lockout. Do not change it in production. |
NGINX_CONTAINER | npg-proxy | The nginx container the API runs nginx -t and reloads in |
NGINX_SKIP_TEST | false | true skips the nginx -t check before applying. A broken configuration could then be applied, so leave it alone. |
NGINX_STATUS_URL | http://host.docker.internal: + NGINX_HTTP_PORT + /nginx_status | nginx status address for dashboard statistics |
NGINX_ACCESS_LOG | /etc/nginx/logs/access_raw.log | The access log file the API reads |
BACKUP_PATH | /app/data/backups | Where backup files are stored (the npg_api_data volume) |
Related pages
- Installation steps and creating
.env: Installation - Containers and volumes: Architecture