Server — Configuration
Common environment variables
This is a practical summary, not the complete configuration contract. Use the
server repository’s .env.example
for every supported setting, its current default, and its security notes.
WEB_PORT(5866)TZ(America/New_York)SECRET_DIR(/kypost/private). Each*_KEY_FILEand*_SECRET_FILEdefault derives from this.OLLAMA_BASE_URL(http://127.0.0.1:11434)OLLAMA_MODEL(nemotron-3-nano:4b). See classifier note below.TUNING_FILE(/kypost/config/TUNING.md)OLLAMA_MODELS_HOST_DIR(./share/ollama/models)IMAP_CONFIG_FILE($SECRET_DIR/imap-config.json)IMAP_CONFIG_KEY_FILE($SECRET_DIR/imap-config.key)TOTP_SECRET_KEY_FILE($SECRET_DIR/totp-secret.key)SERVER_BASE_URL(optional, recommended for pairing; the server embeds this public URL assrvin the QR code and uses it to buildreg)PAIRING_SECRET(optional; HMAC secret for pickup links, PGP QR, pairing tokens; generated on first start atPAIRING_SECRET_FILE; set it only if replicas must share one; useopenssl rand -base64 32; value must be 32 bytes or longer)PAIRING_SECRET_FILE($SECRET_DIR/pairing.key)PUSH_RELAY_URL(optional; base URL of the FCM relay Worker; must behttps://except for loopback)PUSH_RELAY_KEY(per-server API key; set withPUSH_RELAY_URLto enable Android push)APNS_RELAY_URL(optional; base URL of the APNs relay Worker; must behttps://except for loopback)APNS_RELAY_KEY(per-server API key; set withAPNS_RELAY_URLto enable iOS push)CAPTCHA_PROVIDER(optional;pow,turnstile,friendly, ornone; works with 3-strikes/15-minute lockout)CAPTCHA_SITE_KEYandCAPTCHA_SECRET_KEY(required withturnstileorfriendly, not withpow)POW_MAX_NUMBER,POW_SECRET_FILE,POW_SECRET(optional,CAPTCHA_PROVIDER=powonly; see.env.example)KYPOST_BIND(required by Compose;.env.examplestarts at127.0.0.1)TRUSTED_PROXY_CIDRS(optional; narrowly identifies proxies whose forwarded headers may be trusted)TLS_CERT_FILEandTLS_KEY_FILE(optional; required together for direct TLS termination)ALLOW_INSECURE_HTTPandALLOW_INSECURE_SMTP(optional, default off; explicit security downgrade acknowledgements)BOOTSTRAP_ADMIN_USERandBOOTSTRAP_ADMIN_PASS(optional, first run only)
The image also sets OLLAMA_MODELS=/kypost/ollama-models. The classifier default appears in four places: Dockerfile, docker-compose.yml, .env.example, and backend fallback. All use nemotron-3-nano:4b.
TLS options
There are three ways to get TLS. They are not equivalent.
-
Terminate TLS in KyPost. Set
TLS_CERT_FILEandTLS_KEY_FILEto mounted paths (see.env.exampleand the commented volume indocker-compose.yml). The server answers “did this arrive over TLS” from the connection.TRUSTED_PROXY_CIDRSdoes not apply. Renewals apply without a restart. You must set both files or you get a startup error. -
Cloudflare Tunnel.
cloudflaredgives the browser a real HTTPS origin. No TLS config of your own. -
Reverse proxy you run (nginx, Caddy).
Options 2 and 3 need TRUSTED_PROXY_CIDRS set to the proxy address, for example 127.0.0.1/32 or a pinned address on kypost-net (for example 10.89.0.10/32). Name the proxy address narrowly, not a wide range, or a peer in the range can forge X-Forwarded-For. Behind Cloudflare, the server reads CF-Connecting-IP before X-Forwarded-For.
For network layout and DNS details see
docs/Reverse_Proxy_Networking.md.
Choosing a classifier model
Measured on a 60-email benchmark, five repeats, zero run-to-run variance:
| Model | Unambiguous mail | Keyword traps | Prompt injection | RAM resident |
|---|---|---|---|---|
nemotron-3-nano:4b (default) | 100% | 75% | 63% | 2.9 GB |
gemma4:e4b | 100% | 75% | 88% | 8.8 GB |
Speed is not tabulated. It depends on CPU and host load. The same request varied from 13 to 19 seconds on one machine as background load changed. The two models were within 20% under identical conditions. The poller paces at one message every three seconds.
Use gemma4:e4b if the host has 12 GB or more free.
Per-user tuning
- Each user connects his own IMAP mailbox.
- Each account has its own label list, copied from instance defaults at creation.
- Each user has his own tuning prompt and his own decisions page.
- Label rules are instance-wide (Server tab). Email Labels are per-user.