Skip to content

Configuration

The complete template is in .env.example in the Relay repository. These are the most important values:

Variable Purpose Typical value
PORT Container/application HTTP port 3000
APP_PORT Host port used by Docker Compose 3000
NODE_ENV production / development / test — unset is refused (no guessing) production
HOST Address the server binds to (not a URL) 127.0.0.1
APP_BIND_ADDRESS Effective bind address; wins over HOST when set (hostname/IP only, IPv6 may be [::1]); default loopback-only unset → falls back to HOST
APP_BASE_URL Exact public origin; required in production; bare origin only (see below) https://relay.example.com
EXTRA_ALLOWED_ORIGIN One extra browser origin for CORS + Socket.IO; same bare-origin rule unset
TRUST_PROXY Trusted reverse-proxy hops or CIDRs loopback, linklocal, uniquelocal
JWT_SECRET Signs login tokens; minimum 32 characters Random secret
SESSION_SECRET Signs cookies and worker commands; minimum 32 characters Different random secret
WA_SESSION_ENCRYPTION_KEY Encrypts stored WhatsApp credentials; falls back to SESSION_SECRET if unset Random secret
ADMIN_USERNAME Initial administrator username admin
ADMIN_PASSWORD Initial administrator password; minimum 8 characters Strong unique password
MONGODB_URI MongoDB connection URI — required in production (no localhost default) mongodb://localhost:27017/leviro-relay (dev only)
REDIS_HOST / REDIS_PORT Redis connection — REDIS_HOST required in production localhost / 6379
REDIS_PASSWORD Optional Redis password Empty for the private Compose network
WORKER_MODE separate or single separate
MAX_FILE_SIZE_MB Maximum uploaded file size 50
GALLERY_MAX_MB Gallery quota a fresh install starts with 2048
LOG_LEVEL Log level info

ADMIN_USERNAME and ADMIN_PASSWORD create the first administrator only when the database has no admin record. Later changes are managed from Settings.

APP_BASE_URL and EXTRA_ALLOWED_ORIGIN must be bare origins: scheme + host, plus a non-standard port if any — no path, query, fragment, or userinfo. A lone trailing slash is tolerated and stripped. Values with a path (for example https://relay.example.com/app) are refused at startup. HOST / APP_BIND_ADDRESS are bind addresses, never URLs and never the public origin — the public origin is APP_BASE_URL.

Terminal window
openssl rand -hex 32 # JWT_SECRET
openssl rand -hex 32 # SESSION_SECRET
openssl rand -base64 32 # WA_SESSION_ENCRYPTION_KEY
openssl rand -base64 32 # ADMIN_PASSWORD

Production startup refuses to start when:

  • a required secret is missing,
  • a known example/placeholder secret is used,
  • JWT_SECRET equals SESSION_SECRET,
  • WA_SESSION_ENCRYPTION_KEY equals either of them,
  • the administrator password is a known insecure example value,
  • NODE_ENV is invalid or unset,
  • a required configuration value is malformed, or
  • APP_BASE_URL is missing.

It never silently substitutes production secrets with development defaults. In development, missing secrets are generated into data/.dev-secrets.json (0600) instead.

Encryption keys — read this before you touch them

Section titled “Encryption keys — read this before you touch them”

WA_SESSION_ENCRYPTION_KEY encrypts the paired device’s WhatsApp credentials at rest (AES-256-GCM). Those records are the account: whoever can read them can send and read messages as you, with no QR scan.

  • Changing or losing the key is a breaking change. Nothing stored alongside the data can recover the old key. Stored credentials become undecryptable, the dashboard reports that the saved session cannot be read, and the only recovery is logging out and pairing again.
  • Set it once, before pairing, and back it up separately from the database — never inside a backup archive.
  • If it is left unset, the app falls back to SESSION_SECRET, so setting it later (or changing SESSION_SECRET while it is unset) breaks the stored session in exactly the same way.

The same warning applies to encrypted backup and webhook credentials: a backup restored without the encryption secret cannot decrypt them.

  • Rate limiting: RATE_LIMIT_WINDOW_MS (900000) and RATE_LIMIT_MAX_REQUESTS (100) by default.
  • Queue: QUEUE_MAX_RETRIES (5), QUEUE_RETRY_DELAY_MS (5000). WhatsApp sends run one at a time, at most 30 per minute with jitter — do not raise this without a reason; it is ban-safety.
  • Telegram queue: TELEGRAM_QUEUE_CONCURRENCY (3), TELEGRAM_RATE_LIMIT_MAX (20 per minute).
  • Uploads: ALLOWED_MIME_TYPES defaults cover images, video, audio, documents, and archives; channels (WhatsApp newsletters) reject documents regardless.
  • State: DATA_ROOT is where data/, uploads/, gallery/, and logs/ live. In Compose it is /app/state on one shared named volume.
  • Telegram: the bot token is stored as AES-256-GCM ciphertext and is configured from the Telegram page, not only from .env (TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID are optional there). Personal-account login needs TELEGRAM_API_ID / TELEGRAM_API_HASH from https://my.telegram.org/apps.
  • S3 destinations: a private/loopback endpoint is refused by default; a self-hosted MinIO destination opts in per-destination with allowPrivateEndpoint: "true" (see Backups & recovery).