Skip to content
Documentation

Production environment variables

Look up the production image, origin, domain, secret, storage, authentication, email, proxy, worker, and lifecycle settings Nibleaf consumes.

  • 16 min read
  • Updated

Start from .env.production.example shipped with the release. This page explains the setting groups for the current source. The pinned v0.2.1 Compose file and its image have a separate release boundary. Never commit a populated .env.

The first tables use production Compose defaults unless marked otherwise. The search, analytics, connection, and logging tables below give schema defaults. An empty value is treated as unset by the env schemas. Optional means the process can parse without it; a feature may still require it. A value in .env does not reach a container unless Compose passes it in environment or env_file. See the release wiring notes at the end before changing a setting.

VariableRequiredDefaultPurpose
NIBLEAF_VERSIONYes in practicev0.2.1 in the current templateGHCR release tag. Pin an existing release; avoid floating tags. The manual Docker workflow rejects overwriting an existing v* release tag, making published version tags immutable by repository policy.
APP_URLYesNoneBrowser-facing dashboard and normal authentication origin, without a trailing slash.
ADMIN_URLOnly when admin is exposedhttp://localhost:4315Public origin for the optional operator console.
NIBLEAF_BINDNo127.0.0.1Host interface for the app port. Keep loopback when the proxy is local.
APP_PORTNo4310Host port mapped to the app container.
BETTER_AUTH_URLNoAPP_URLExplicit authentication base override.
TRUSTED_ORIGINSNoAPP_URLComma-separated authentication origins. Include both APP_URL and ADMIN_URL when the operator console is exposed so native support impersonation can begin there.
CORS_ALLOWED_ORIGINSNoAPP_URLComma-separated API origins. Include both APP_URL and ADMIN_URL when the operator console calls the shared API directly.
PINO_LOG_LEVELNoinfo in productionMinimum structured log level.
PINO_LOG_FILENoEmptyDeprecated compatibility setting in current source: only its parent directory selects the evlog file drain; the requested filename is not preserved. Prefer EVLOG_FS_DIR. Mount the directory to persist logs.
VariableRequiredDefaultPurpose
SITE_BASE_DOMAINNoEmptyEnables <project>.<base-domain> publishing; requires wildcard DNS and TLS.
CUSTOM_DOMAIN_CNAME_TARGETNoSITE_BASE_DOMAINOperator-controlled CNAME target shown to custom-domain owners.
CUSTOM_DOMAIN_PROVIDERNoingressCustom-domain automation strategy supported by the release.
CLOUDFLARE_SAAS_ZONE_IDFor Cloudflare for SaaSEmptyZone identifier for managed custom hostnames.
CLOUDFLARE_SAAS_API_TOKENFor Cloudflare for SaaSEmptyNarrow token for custom-hostname operations.
CLOUDFLARE_SAAS_WORKER_SCRIPTNonibleaf-custom-domain-edgeEdge worker script name.
CUSTOM_DOMAIN_EDGE_SECRETFor the managed edge pathEmptyShared edge-to-origin authentication secret.
VariableRequiredPurpose
BETTER_AUTH_SECRETYesSigns authentication state and encrypts the MCP OAuth signing keys. Generate independently with openssl rand -hex 32. After rotating it, delete the rows in the jwks table so new signing keys are created; otherwise OAuth token requests fail with a server error. Connected AI apps then sign in again.
POSTGRES_PASSWORDYesPassword for the bundled Nibleaf database user.
INTERNAL_API_SECRETStrongly recommendedAuthenticates trusted app-to-API hints used for accurate rate limiting.
VariableRequiredDefaultPurpose
STORAGE_PROVIDERNomaxioProvider behavior such as maxio, r2, or another supported S3-compatible mode.
STORAGE_ENDPOINTFor external storagehttp://maxio:9000Server-to-storage endpoint.
STORAGE_PUBLIC_ENDPOINTYesNoneBrowser-reachable origin used for presigned requests.
STORAGE_ACCESS_KEY_IDYesNoneBucket access identifier.
STORAGE_SECRET_ACCESS_KEYYesNoneBucket secret. Generate independently.
STORAGE_BUCKETNonibleafAsset and export bucket.
STORAGE_REGIONNoautoS3 region value.
STORAGE_FORCE_PATH_STYLENotrueUse path-style bucket URLs; AWS S3 commonly uses false.
STORAGE_PUBLIC_URLRecommendedEmptyPublic asset base, often a bucket or CDN URL.
STORAGE_CORS_ALLOWED_ORIGINSNoAPP_URLBrowser origins allowed to upload directly.
STORAGE_AUTO_CORSNotrueLet Nibleaf configure supported bucket CORS automatically.
MAXIO_SECURE_COOKIESNotrueRequire HTTPS for bundled maxio console cookies.
VariableRequiredDefaultPurpose
DISABLE_SIGNUPNofalseClose new registration while preserving existing sign-in.
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETFor Google sign-inEmptyOAuth client credentials.
EMAIL_FROMFor deliverynibleaf@localhostProvider-verified sender.
POSTMARK_API_KEYFor PostmarkEmptyServer token; preferred when set.
POSTMARK_MESSAGE_STREAMNoEmptyPostmark stream.
SMTP_URLFor SMTP fallbackEmptyFull SMTP connection URL. Protect it as a secret.
EMAIL_DELIVERY_REQUIREDNotrue in productionReturn an unhealthy worker status and fail queued email jobs when no provider is configured.

Create a Web application OAuth client in Google Cloud, then configure:

  • Authorized JavaScript origin: the exact APP_URL, such as https://nibleaf.example.com.
  • Authorized redirect URI: ${APP_URL}/api/auth/callback/google.
  • GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET: the matching client credentials.

Both variables must be present and non-blank after trimming surrounding whitespace. Nibleaf hides the Google button when either value is missing, so a partially configured provider cannot send readers into a broken sign-in flow. Restart the application after changing these server-side values.

VariableRequiredDefaultPurpose
OPENROUTER_API_KEYFor editor drafting or instance-managed AIEmptyInstance OpenRouter credential for drafting, embeddings and answers. A selected workspace search connection uses its own saved key.
AI_DRAFT_MODELNoopenai/gpt-6-lunaOpenRouter model used for explicit editor writing actions.
AI_DAILY_LIMITNo50Per-workspace daily editor-drafting request limit; 0 disables drafting.
MARKETING_GTM_IDNoEmptyPreferred GTM container ID for public instance marketing pages. It is public metadata and loads only after explicit visitor consent. Configure the GA4 Google tag in GTM with automatic pageviews disabled; Nibleaf pushes one manual page_view per accepted route plus allowlisted events. This variable takes precedence over MARKETING_GA4_ID.
MARKETING_GA4_IDNoEmptyLegacy direct-GA4 fallback for existing self-hosters. It loads only after explicit consent and is ignored when MARKETING_GTM_ID is configured.
RATE_LIMIT_PUBLIC_PER_MINNo300Public site-serving requests per address per minute.
TRUSTED_PROXY_HOPSNo0Number of addresses after the client in X-Forwarded-For, private ones included. Set the same value on the app and API; see how to count them.

When MARKETING_GTM_ID is enabled, configure one Google tag in GTM with automatic pageviews disabled and its normal page initialization trigger. Then configure one GA4 Event tag triggered by the Custom Event nibleaf_marketing_event, with its GA event name read from the Data Layer Variable event_name. Nibleaf uses that stable envelope for the allowlisted names page_view, sign_up, cta_clicked, free_tool_started, free_tool_completed, and free_tool_cta_clicked, so six separate GTM Event tags are not required. Map only the documented safe event variables. Do not add variables that read form fields, account data, document content, or arbitrary DOM values into analytics. Keep consent checks enabled on both tags. Nibleaf loads the container only after acceptance, pushes one manual page_view for the accepted route and each later SPA navigation, and stops event delivery when consent is withdrawn.

VariableRequiredDefaultPurpose
MCP_ENABLEDNofalseEnables the authenticated project-bound /api/mcp endpoint. Keep it disabled until proxy and key-lifecycle checks pass.
MCP_ALLOWED_HOSTSNoEmptyComma-separated additional public hostnames. API_URL and APP_URL hosts are already allowed. Schemes, paths, wildcard values, and ambiguous forwarded chains are rejected.
MCP_RATE_LIMIT_PER_MINNo120Per-key MCP requests of any kind accepted by one API process per minute. Counters are in memory per process; add an ingress/shared-edge limit for deployment-wide enforcement.
MCP_WRITE_RATE_LIMIT_PER_MINNo20Per-key write tool calls (page drafts, edits, moves, translations, visibility, and publishes) accepted by one API process per minute. preview_publish does not count.
MCP_PUBLISH_RATE_LIMIT_PER_HOURNo6Per-key publish_changes attempts accepted by one API process per hour. Only attempts that pass the preview-token check count.

See secure MCP client setup and operations before enabling the endpoint. API keys are personal: each member creates their own, admins can revoke any but only the owner can rotate one, and secrets are displayed once. They must not be stored in environment examples or repository configuration.

VariableRequiredDefaultPurpose
EXPORT_CHROMIUM_PATHFor PDF outside the official image/usr/bin/chromium-browserChromium-compatible executable used for PDF rendering.
EXPORT_CONCURRENCYNo2Export jobs processed by one worker; accepted range is 1–8.
EXPORT_MAX_ACTIVE_PER_PROJECTNo3Concurrent project runs accepted by the API.
EXPORT_MAX_DAILY_PER_PROJECTNo20Per-project daily run limit.
EXPORT_MAX_PAGESNo5000Maximum pages copied into one immutable export snapshot.
EXPORT_MAX_SNAPSHOT_BYTESNo52428800Maximum serialized snapshot bytes.
EXPORT_MAX_ASSET_BYTESNo262144000Maximum referenced asset bytes copied into an artifact.
EXPORT_MANUAL_RETENTION_DAYSNo7Retention for one-time export runs.
EXPORT_DOWNLOAD_TTL_SECONDSNo300Presigned download lifetime; accepted range is 30–900 seconds.

The official image includes Chromium. If WORKER_QUEUES is a comma-separated allowlist, include export; an empty value enables every queue. An allowlist must also include erasure, or the stored objects of deleted projects stay in storage. See Operate hybrid search and grounded answers.

VariableRequiredDefaultPurpose
GIT_CREDENTIAL_ENCRYPTION_KEYTo enable two-way GitNoneExactly 32 bytes encoded as base64; encrypts provider credentials and webhook secrets.
GIT_WORKER_SECRETTo enable two-way GitNoneAt least 32 characters shared by API and worker for opaque callbacks.
GIT_CONCURRENCYNo2Git operations processed by one worker.

Generate the two secrets independently. Do not rotate the encryption key in place: existing ciphertext cannot be decrypted with a new key. Follow the Git authoring rotation procedure. If WORKER_QUEUES is set, include git.

VariableRequiredDefaultPurpose
INTEGRATION_CREDENTIAL_ENCRYPTION_KEYFor webhook and workspace AI credentialsNoneIndependent 32-byte base64 key for versioned AES-256-GCM credential envelopes and purpose-separated HMAC digests. Do not reuse the Git key.
INTEGRATION_CREDENTIAL_PREVIOUS_KEYSDuring key rotation onlyEmptyComma-separated prior integration keys accepted for decrypt and digest lookup during a bounded dual-read window.
INTEGRATION_CONFIRMATION_TTL_SECONDSNo300Lifetime of a one-time, revision-bound integration delete confirmation; accepted range is 60–1800 seconds.
INTEGRATION_CONFIRMATION_RETENTION_HOURSNo24Retention for consumed confirmation tombstones before bounded cleanup; accepted range is 1–168 hours. Expired unconsumed challenges are removed on the next project challenge.
INTEGRATION_IDEMPOTENCY_TTL_HOURSNo24Retention for secret-free durable mutation replays; accepted range is 1–168 hours.

Follow the rotation and rollback procedure in Integrations engine.

VariableRequiredDefaultPurpose
WORKBENCH_USER, WORKBENCH_PASSRecommendedEmptyBasic authentication for worker operations at port 4312.
NIBLEAF_RUN_SEEDNofalseSeed demo content during migration; keep false in production.
SERVER_SHUTDOWN_TIMEOUT_MSNo25000API drain timeout in milliseconds.
NIBLEAF_SHUTDOWN_GRACENo30sContainer stop grace; keep longer than the server timeout.

After changing origins, secrets, or storage, recreate the affected services and repeat the workflow checks in production readiness.

VariableSchema defaultRequirement and effect
QDRANT_URLunsetRequired for hybrid retrieval; HTTP(S) Qdrant endpoint.
QDRANT_API_KEYunsetOptional client key; provision authentication on Qdrant itself too.
QDRANT_COLLECTION_ALIASnibleaf_search_activeStable read alias; letters, digits, underscore and hyphen only.
QDRANT_COLLECTION_VERSIONv2Physical collection generation; v followed by a positive integer.
QDRANT_VECTOR_SIZESEARCH_EMBEDDING_DIMENSIONS (3072)Dense-vector dimensions, 64–8192; must match embedding dimensions, and follows them when unset.
QDRANT_TIMEOUT_MS8000Qdrant request timeout, 250–120000 ms.
SEARCH_RUNTIMEshadowlegacy returns Orama; shadow returns Orama while evaluating hybrid; hybrid uses Qdrant.
SEARCH_FUZZY_TOLERANCE2Typo tolerance, 0–3; shorter query tokens use less tolerance.
SEARCH_EMBEDDING_MODELopenai/text-embedding-3-largeInstance-owned model for API retrieval and worker indexing.
SEARCH_EMBEDDING_DIMENSIONS3072Embedding width, 64–8192; changing it requires a compatible new collection.
SEARCH_EMBEDDING_TIMEOUT_MS20000Embedding provider timeout, 500–120000 ms.
SEARCH_CANDIDATE_LIMIT48Retrieval candidates, 10–200.
SEARCH_DENSE_MIN_SCORE0.35Cosine-score threshold before rank fusion, -1 to 1.
SEARCH_CACHE_TTL_MS60000Search cache lifetime, 0–3600000 ms.
SEARCH_ANSWER_ENABLEDfalseEnables instance-managed answers; workspace selection and site opt-in are separate.
SEARCH_ANSWER_MODELopenai/gpt-6-lunaInstance answer model; a selected workspace connection has its own model.
SEARCH_ANSWER_TIMEOUT_MS30000Answer provider timeout, 1000–120000 ms.
SEARCH_ANSWER_DAILY_PER_PROJECT200Daily project answer quota, 0–100000; each chat question also counts.
SEARCH_ANSWER_RATE_LIMIT_PER_MIN10Per-IP minute limit, 1–1000; separate buckets for answer and chat routes.
SEARCH_ANSWER_MIN_CONFIDENCE0.2Minimum retrieval confidence for an answer, 0–1.
SEARCH_CHAT_MAX_TURNS20Questions per conversation, 1–200.
SEARCH_CHAT_MAX_CONVERSATION_TOKENS150000Conversation token budget, 1000–10000000. The current search overlay and production example set 60000 instead; set 150000 explicitly for the schema default.
SEARCH_CHAT_DAILY_TOKENS_PER_PROJECT2000000UTC-day project token budget, 0–1000000000; 0 disables this budget.
SEARCH_CHAT_HISTORY_MESSAGES6Prior messages supplied per turn, 0–12.
SEARCH_CHAT_HISTORY_MAX_TOKENS1500Estimated history token cap, 0–16000.
SEARCH_CHAT_UTILITY_MODELunsetOptional OpenRouter rewrite/suggestions model, 1–120 characters; unset uses the answer model.
SEARCH_CHAT_SUGGESTIONS_TIMEOUT_MS15000Suggestions timeout after the checked answer, 1000–60000 ms.
VariableSchema defaultRequirement and effect
ANALYTICS_MODEdisableddisabled, dual_write, shadow_read or clickhouse; see the staged analytics guide.
ANALYTICS_HASH_SALTunsetRequired for ClickHouse event ingestion; missing salt drops events. Preserve the existing secret.
CLICKHOUSE_URLhttp://localhost:8123ClickHouse HTTP endpoint; source containers use http://clickhouse:8123.
CLICKHOUSE_DATABASEnibleaf_analyticsDatabase name: letter or underscore first, then letters, digits or underscore; at most 63 characters.
CLICKHOUSE_READER_USERNAMEdefaultSELECT identity; provision the user and grants separately.
CLICKHOUSE_READER_PASSWORDunsetReader password; optional in schema, required when the server user requires it.
CLICKHOUSE_WRITER_USERNAMEdefaultWriter identity; worker also needs reads, erasure, and DDL if boot migrations are on.
CLICKHOUSE_WRITER_PASSWORDunsetWriter password; keep it in deployment secrets.
CLICKHOUSE_REQUEST_TIMEOUT_MS5000Transport deadline, 250–60000 ms.
CLICKHOUSE_MAX_BATCH_SIZE500Maximum events per batch, 1–10000.
CLICKHOUSE_MAX_BUFFERED_EVENTS10000Buffer bound, 100–100000 events; not a replacement for durable queues.
CLICKHOUSE_FLUSH_INTERVAL_MS1000Batch flush interval, 25–30000 ms.
CLICKHOUSE_RAW_RETENTION_DAYS180Human raw-event retention, 7–730 days.
CLICKHOUSE_CRAWLER_RETENTION_DAYS90Crawler raw-event retention, 7–730 days.
CLICKHOUSE_ROLLUP_RETENTION_DAYS730Aggregate retention, 30–3650 days.
CLICKHOUSE_SENSITIVE_RETENTION_DAYS30Opted-in public search-text retention, 1–90 days.
CLICKHOUSE_MIGRATE_ON_BOOTtrueWorker retries schema migrations in the background; false needs a migration operator.
AI_CONVERSATION_ENCRYPTION_KEYunsetOptional 32-byte base64 queue-encryption key on API and worker; otherwise derived from the integration key. With neither key, no conversation text is saved.
AI_CONVERSATION_RETENTION_DAYS90Conversation turns and feedback TTL, 1–365 days; same value on API, worker and migration CLI.
VariableSchema defaultRequirement and effect
NODE_ENVdevelopmentdevelopment, test or production; the official image uses production.
POSTGRES_URLpostgresql://nibleaf:nibleaf@localhost:5442/nibleafDirect-process development default only. Production Compose constructs it from POSTGRES_PASSWORD and postgres:5432; do not use development credentials in production.
REDIS_HOSTlocalhostQueue host; production Compose fixes it to dragonfly.
REDIS_PORT6379Queue port; production Compose fixes it to 6379.
REDIS_PASSWORDunsetOptional queue authentication.
REDIS_DB0Queue database number.
QUEUE_CLUSTERtrueHash-tags queue names; keep consistent with Dragonfly hashtag locking.
WORKER_QUEUESemptyComma-separated worker allowlist; empty runs all queues. Include export, git, analytics, search and erasure as needed.
PUBLISH_CONCURRENCY2Publish jobs per worker.
SEARCH_CONCURRENCY4Search/index jobs per worker.
EMAIL_CONCURRENCY3Email jobs per worker.
ANALYTICS_CONCURRENCY10Analytics jobs per worker.
APP_NAMENibleafAPI application name.
API_PORT4311API listener; fixed to 4311 by production Compose.
WORKER_PORT4312Worker listener; fixed to 4312 by production Compose.
API_URLhttp://localhost:4311API origin; production Compose uses http://server:4311.
PORT4310 / 4315Dashboard/admin listener respectively; separate from the host APP_PORT mapping.
NITRO_PORTunsetOptional Nitro listener override for app/admin.
SERVICE_NAMEnibleaf-api / nibleafAPI health label / logger default respectively.
ALLOW_SEEDunsetExplicit opt-in for the production seed guard; migration entrypoint passes 1 only when seeding was requested.
CDN_URLunsetOptional public asset CDN base in the storage package.
VariableSchema defaultRequirement and effect
EVLOG_LOG_LEVELinfo / debugProduction / development fallback; error, warn, info, debug or silent. Overrides PINO_LOG_LEVEL.
EVLOG_FS_DIRunsetOptional JSONL drain directory; overrides the parent directory from PINO_LOG_FILE.
EVLOG_FS_MAX_FILES14Positive number of retained drain files.
EVLOG_FS_MAX_SIZE_BYTES10000000Positive maximum size per drain file.
VITE_APP_URLhttps://nibleaf.comBuild-time public URL; localhost:4310 in development. Admin server also accepts a runtime override. Never put secrets in VITE_ variables.
VITE_ADMIN_URLhttps://admin.nibleaf.comApp build-time admin URL; localhost:4315 in development.
VITE_GITHUB_URLhttps://github.com/lord007tn/nibleafApp build-time repository link.
VITE_SITE_BASE_DOMAINunsetOptional app build-time project-domain value.

The pinned docker-compose.prod.yml for v0.2.1 has no ClickHouse or Qdrant service. It does not pass analytics variables, search variables, AI_DRAFT_MODEL, MCP_WRITE_RATE_LIMIT_PER_MIN, MCP_PUBLISH_RATE_LIMIT_PER_HOUR, WORKER_QUEUES, export tuning, or the new EVLOG_* settings. The corresponding values in .env.production.example are not proof that they reach a service. A newer setting also requires an image that implements it; adding an environment variable cannot add a feature to an older image.

For a reviewed current-source deployment, put missing settings in a separate Compose override. For example, this docker-compose.operator.yml passes two MCP controls and a worker queue allowlist (the listed queues enable all current workers):

yaml
services:
  server:
    environment:
      MCP_WRITE_RATE_LIMIT_PER_MIN: ${MCP_WRITE_RATE_LIMIT_PER_MIN:-20}
      MCP_PUBLISH_RATE_LIMIT_PER_HOUR: ${MCP_PUBLISH_RATE_LIMIT_PER_HOUR:-6}
  worker:
    environment:
      WORKER_QUEUES: ${WORKER_QUEUES:-publish,search,email,analytics,export,git,erasure}

Include that file in every subsequent operation:

bash
docker compose -f docker-compose.prod.yml -f docker-compose.operator.yml config --services
docker compose -f docker-compose.prod.yml -f docker-compose.operator.yml up -d

In an installer directory use docker-compose.yml as the first file. Keep any search or analytics overrides in the same command as well. Do not publish the full rendered configuration; it contains secrets.

docker-compose.search.yml adds Qdrant and a subset of search/chat variables to API and worker. It does not configure authentication on the Qdrant service when you set only the client-side QDRANT_API_KEY. Provision the server key too before exposing Qdrant. SEARCH_CHAT_SUGGESTIONS_TIMEOUT_MS and several advanced search knobs are not passed by that overlay; add explicit environment mappings if you change them. Its 60000-token cap differs from the schema default above.

Source quickstart (docker-compose.yml) and Coolify include ClickHouse, backup disk configuration and the analytics-tools profile. Their bootstrap settings include CLICKHOUSE_USERNAME / CLICKHOUSE_PASSWORD (quickstart fallback nibleaf / nibleaf), or SERVICE_PASSWORD_64_CLICKHOUSE (required in Coolify). These create service credentials; the app uses reader/writer variables instead. Do not use quickstart credentials for a public deployment.

Coolify also uses NIBLEAF_IMAGE_TAG (fallback latest), SERVICE_USER_POSTGRES, SERVICE_PASSWORD_64_POSTGRES, POSTGRES_DB (fallback nibleaf), SERVICE_HEX_64_NIBLEAF, and storage fallbacks SERVICE_USER_STORAGE and SERVICE_PASSWORD_64_STORAGE. Set an explicit image tag and keep the generated secrets. These are Compose inputs, not app schema variables. Review that file before moving a portable .env into Coolify.

After recreating services, verify their actual behavior: health, an upload, publishing, search, and any optional feature you enabled. A parsed environment or a passing health endpoint does not prove mail delivery, AI provider credit, index quality, or backup recovery.

Was this page helpful?