Configure a production deployment
Set public origins, independent secrets, object storage, email, domain routing, proxy trust, and operator access for self-hosted Nibleaf.
- 5 min read
- Updated
On this page
Copy .env.production.example from the release you are deploying. It is the
authoritative setting template. Pin an image, set browser-reachable public
origins, generate independent secrets, and keep internal services private.
The pinned v0.2.1 production Compose file does not include ClickHouse or pass
its variables. The analytics table below describes current-source settings;
provision the service and explicit API/worker environment mappings before using
it. A variable in .env is not automatically passed to a container. See
release wiring.
APP_URL is the browser-facing dashboard origin and authentication base for a
normal deployment. Do not add a trailing slash. Keep NIBLEAF_BIND=127.0.0.1
when a reverse proxy runs on the same host.
SITE_BASE_DOMAIN enables project hosts such as
project.docs.example.com; it needs wildcard DNS and wildcard TLS.
CUSTOM_DOMAIN_CNAME_TARGET is a hostname you operate that customer domains
can target. Leave optional domain features empty until their DNS and TLS path is
ready.
Generate secrets on the target host:
openssl rand -hex 32
openssl rand -base64 24
Use separate random values for authentication, the internal API, Postgres, and object storage. Do not copy values from an example, development deployment, support request, or another environment. The production entrypoint rejects known demo authentication secrets.
Two-way Git requires an exactly 32-byte base64 encryption key and a separate API/worker secret of at least 32 characters:
openssl rand -base64 32
openssl rand -hex 32
Deploy GIT_CREDENTIAL_ENCRYPTION_KEY and GIT_WORKER_SECRET to the services
listed by the release Compose file. Read the Git key rotation boundary
before enabling a production repository connection.
The server uses STORAGE_ENDPOINT for internal requests. The writer's browser
uses presigned URLs based on STORAGE_PUBLIC_ENDPOINT, so that origin must be
publicly reachable and must match how requests are signed. STORAGE_PUBLIC_URL
is the base used when published pages reference assets.
For bundled maxio, route the public storage hostname to maxio port 9000 through TLS. For R2, S3, Backblaze B2, or another compatible provider, make the endpoint, region, path-style behavior, credentials, bucket, CORS origins, and public URL agree. Upload and open a real image before inviting writers.
Sign-in uses email codes, or Google when GOOGLE_CLIENT_ID and
GOOGLE_CLIENT_SECRET are configured. Set a verified EMAIL_FROM and configure
Postmark or SMTP_URL. Send a sign-in code to an external mailbox; a container
health check cannot prove delivery.
EMAIL_DELIVERY_REQUIRED defaults to true, and the worker health check returns 503
while no provider is configured. Set it to false only for an instance that signs in
through Google: without a provider, the first owner cannot receive an email code.
After creating the intended owners, set DISABLE_SIGNUP=true if registration
should close. Existing accounts can still sign in.
Forward the original host and HTTPS scheme. Set TRUSTED_PROXY_HOPS to the
number of addresses after the client in X-Forwarded-For, private ones
included, only after capturing the real chain each service receives and
configuring the ingress to discard untrusted forwarded headers. See
Readers see “Too many requests”
for worked examples. A value that is too high lets clients
influence the address used for rate limiting; a value that is too low groups
traffic under the proxy.
Only the app binds a host port in the production Compose file. Keep Postgres, Dragonfly, the API, the worker, maxio administration, and the optional admin app on the Docker network, loopback, or a private VPN.
Set both WORKBENCH_USER and WORKBENCH_PASS even when worker port 4312 is not
published. Use an SSH tunnel when an operator needs the jobs dashboard.
Review the complete environment-variable reference, then run the production checklist. If the site will be private, complete the reader-access recovery procedure before sending invitations.
| Variable | Default | Guidance |
|---|---|---|
ANALYTICS_MODE | disabled in production template | Advance through dual_write, shadow_read, then clickhouse after reconciliation. |
ANALYTICS_HASH_SALT | unset | Required for enabled ClickHouse ingestion: missing salt drops events. Generate only for new installations with openssl rand -hex 32; preserve existing values. |
CLICKHOUSE_URL | http://localhost:8123 in code | Source quickstart and Coolify use http://clickhouse:8123; protect remote transport with TLS. |
CLICKHOUSE_DATABASE | nibleaf_analytics | Same value for API, worker and migration CLI. |
CLICKHOUSE_READER_USERNAME / CLICKHOUSE_READER_PASSWORD | default / unset in code | Production: separate SELECT-only reader; Compose bootstrap defaults differ. |
CLICKHOUSE_WRITER_USERNAME / CLICKHOUSE_WRITER_PASSWORD | default / unset in code | INSERT plus SELECT on tombstones; add reader/erasure roles for worker duties and schema privileges for boot migrations, or use a dedicated CLI identity. |
CLICKHOUSE_REQUEST_TIMEOUT_MS | 5000 | 250–60000; bounds each transport request. |
CLICKHOUSE_MAX_BATCH_SIZE | 500 | 1–10000 events. |
CLICKHOUSE_MAX_BUFFERED_EVENTS | 10000 | 100–100000 events; queue persistence remains necessary. |
CLICKHOUSE_FLUSH_INTERVAL_MS | 1000 | 25–30000 milliseconds. |
CLICKHOUSE_RAW_RETENTION_DAYS | 180 | 7–730; raw human events. |
CLICKHOUSE_CRAWLER_RETENTION_DAYS | 90 | 7–730; raw crawler events. |
CLICKHOUSE_ROLLUP_RETENTION_DAYS | 730 | 30–3650; aggregates. |
CLICKHOUSE_SENSITIVE_RETENTION_DAYS | 30 | 1–90; opted-in public search text. |
CLICKHOUSE_MIGRATE_ON_BOOT | true | Worker retries in background; false requires explicit migrations. |
CLICKHOUSE_USERNAME and CLICKHOUSE_PASSWORD bootstrap bundled Compose only;
Coolify uses SERVICE_PASSWORD_64_CLICKHOUSE. They are not application client
settings. Set explicit reader/writer credentials consistently with provisioned
users. See analytics operations.