Nginx Proxy Guard

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 the environment: section of the api service.

After changing a value, recreate the containers for it to take effect.

docker compose up -d

Required

VariableDefaultPassedDescription
DB_PASSWORDnonecomposePostgreSQL (TimescaleDB) password. Generate one with openssl rand -base64 24.
JWT_SECRETthe placeholder in composecomposeApplication secret. Replace it with a random value from openssl rand -hex 32.

General

VariableDefaultPassedDescription
TZUTCcomposeTime zone of all containers. Log times, schedules and the hour of the daily notification summary follow it. env.example sets Asia/Seoul.
DB_USERpostgrescomposeDatabase user
DB_NAMEnginx_proxy_guardcomposeDatabase name
DOCKER_API_VERSIONauto-detectedcomposeSet only if auto-detection fails. Synology DSM typically uses 1.41 or 1.43.

Ports and network

VariableDefaultPassedDescription
UI_PORT81composeHost port of the admin panel (HTTPS)
NGINX_HTTP_PORT80composeHTTP 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_PORT443composeHTTPS port nginx listens on
API_HOST_PORT9080composeLoopback port nginx uses to reach the API (open on 127.0.0.1 only). Must not collide with NGINX_HTTP_PORT.
API_HOST127.0.0.1: + API_HOST_PORTcomposeAPI address written into the nginx configuration. Normally left empty.
DNS_RESOLVER127.0.0.53 8.8.8.8add yourselfDNS 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

VariableDefaultPassedDescription
API_RATE_LIMIT_PER_MINUTE600composeRequests 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_MINUTE100composeA 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_CIDRunsetcomposeAddresses 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_RPS100add yourselfA per-IP requests-per-second limit on every API request (counted in API memory)
RATE_LIMIT_ENABLEDonadd yourselffalse 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/32

This 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)

VariableDefaultPassedDescription
REDIS_URLredis://valkey:6379/0composeValkey (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_MBautomaticcomposeUpper 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

VariableDefaultPassedDescription
NPG_DNS_ENTRIES_DISABLEDunsetcompose1 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_INTERVALunset (the settings decide)composeCheck 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.

VariableDefaultPassedDescription
NPG_DB_CONTAINERauto-discoveredcompose (commented)Name of the database container. Set it only when the dashboard says the database disk could not be measured.
NPG_DISK_WARN_PERCENT85compose (commented)Warning line for Disk space running low (%)
NPG_DISK_CRITICAL_PERCENT90compose (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_PERCENT80compose (commented)Line for Disk space back to normal (%)
NPG_DISK_EMERGENCY_COMPRESSoncompose (commented)Emergency compression at the critical line: on, off or dryrun (only reports how much could be compressed)
NPG_DISK_GUARD_DISABLEDunsetadd yourself1 turns off disk alerts, the dashboard storage warning and emergency compression.
NPG_DISK_GUARD_INTERVAL1madd yourselfHow often disks are measured (at least 15 seconds)
NPG_DISK_ALERT_COOLDOWN6hadd yourselfHow 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

VariableDefaultPassedDescription
NPG_DDNS_INTERVALthe settings value (5 minutes by default)add yourselfHow often DDNS checks the public IP (for example 5m). Takes precedence over the settings.
NPG_DDNS_DISABLEDunsetadd yourself1 or true turns the DDNS scheduler off.
NPG_CONTAINER_RECONCILE_INTERVAL30sadd yourselfHow often the container IP of hosts that target a container is re-checked
NPG_CONTAINER_RECONCILE_DISABLEDunsetadd yourself1 or true turns that check off.
NPG_DB_MAX_OPEN80add yourselfMaximum database connections of the API
NPG_DB_MAX_IDLE20add yourselfIdle connections. Reduced to NPG_DB_MAX_OPEN if larger.
NPG_RAW_LOG_ARCHIVE_DIR/archiveadd yourselfPath of the raw log archive directory inside the container
ENABLE_DOCKER_LOGSonadd yourselffalse does not start the container log (system log) collector.
LOG_COLLECTIONtrueadd yourselffalse 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_ORIGINSdevelopment addressesadd yourselfAllowed 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.

VariableValueDescription
PORT8080Port the API listens on inside its container
DATABASE_URLbuilt from DB_USER, DB_PASSWORD, DB_NAMEDatabase connection string
ENVIRONMENTproductiondevelopment 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_CONTAINERnpg-proxyThe nginx container the API runs nginx -t and reloads in
NGINX_SKIP_TESTfalsetrue skips the nginx -t check before applying. A broken configuration could then be applied, so leave it alone.
NGINX_STATUS_URLhttp://host.docker.internal: + NGINX_HTTP_PORT + /nginx_statusnginx status address for dashboard statistics
NGINX_ACCESS_LOG/etc/nginx/logs/access_raw.logThe access log file the API reads
BACKUP_PATH/app/data/backupsWhere backup files are stored (the npg_api_data volume)