Skip to content

Environment and Runtime Configuration ​

LatticeDX separates local development defaults (.env.example, .env.agent, .env.integration) from hardened production configuration (infra/compose/prod.env.example paired with infra/compose/prod.yml). Every secret in prod.yml uses mandatory Docker Compose interpolation syntax ${VAR:?Set VAR} so the stack refuses to start if any required credential is missing.

Keep Secret Files Outside Git

Store production variables in an untracked .env.prod file with chmod 600 permissions, and keep local LLM or integration overrides in untracked .env.agent and .env.integration files. Never place provider credentials or cryptographic secrets into NEXT_PUBLIC_* variables or browser plugin bundles.

1. Environment Separation and Key Generation ​

Local development commands (pnpm dev, pnpm local:up) read from your active shell environment or an untracked root .env file. For production deployments driven by infra/compose/prod.yml, copy infra/compose/prod.env.example to .env.prod outside version control and replace every CHANGE_ME_* placeholder with high-entropy random values.

bash
cp infra/compose/prod.env.example .env.prod
chmod 600 .env.prod

# Generate 64-hex (32-byte) secrets for APP_KEY, ENCRYPTION_FIELD_KEY, and DX_VAULT_MASTER_KEY
openssl rand -hex 32
openssl rand -hex 32
openssl rand -hex 32

# Generate 32-hex (16-byte) secrets for IIoT ingest and Node-RED credentials
openssl rand -hex 16

2. Edge, Gateway, Domains, and CORS ​

These variables control TLS termination in Caddy 2.10, CORS and Redis-backed rate limiting in Apache APISIX 3.19.0, and origin validation inside NocoBase and Fastify middleware.

Edge, Gateway, Domains, and CORS Variables
ParameterTypeDefaultDescription
LATTICE_DOMAINrequired
stringapp.example.comPrimary public FQDN served by Caddy for LatticeDX portals and /api/* routing.
KEYCLOAK_DOMAINrequired
stringauth.example.comPublic FQDN for Keycloak 26.8.2 used by KC_HOSTNAME and browser OIDC redirects.
N8N_DOMAINrequired
stringn8n.example.comPublic FQDN for Stock n8n when --profile n8n is enabled.
LATTICE_ALLOWED_ORIGIN
stringhttps://${LATTICE_DOMAIN}Allowed origin enforced globally by the Apache APISIX cors plugin.
DX_CORS_ALLOWED_ORIGINS
stringhttp://localhost:8080,http://127.0.0.1:8080Comma-separated origin allowlist for NocoBase and Fastify API CORS middleware.
DX_CORS_STRICT
booleantrueRejects requests carrying an Origin header outside the allowed origin list.
DX_TRUST_PROXY
booleantrue (prod)Trusts forwarded client IP headers from reverse proxies for public form rate limiting.
APISIX_PORT
number8080Host loopback port bound by APISIX in local development stacks.
CADDY_HTTP_PORT
number80HTTP listener port on Caddy for ACME challenges and HTTPS redirects.
CADDY_HTTPS_PORT
number443HTTPS TCP/UDP (HTTP/3) listener port on Caddy for production traffic.

3. PostgreSQL 16, Multi-Tenancy RLS, PITR, and Valkey 8.1 ​

LatticeDX isolates core platform metadata (postgres) from application and vector data (nocobase-db running pgvector/pgvector:0.8.1-pg16). In nocobase-db, the nocobase container connects as nocobase_app, a non-superuser role configured with NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS that must differ from NOCOBASE_DB_USER so PostgreSQL enforces FORCE ROW LEVEL SECURITY across all 56 static tables and dynamic latticeCustom* tables.

PostgreSQL 16 and Multi-Tenancy RLS Variables
ParameterTypeDefaultDescription
POSTGRES_PASSWORDrequired
secretlocal-demo-passwordPostgres password for local core.yml development. Never reuse outside loopback.
POSTGRES_SUPERUSERrequired
stringpostgresSuperuser account on the core postgres container for role provisioning and PITR.
POSTGRES_SUPERUSER_PASSWORDrequired
secret—Password for POSTGRES_SUPERUSER on the production postgres container.
LATTICE_DB_PASSWORDrequired
secret—Password for non-superuser role lattice_app owning the lattice database.
KEYCLOAK_DB_PASSWORDrequired
secret—Password for non-superuser role keycloak_app owning the keycloak database.
N8N_DB_PASSWORDrequired
secret—Password for non-superuser role n8n_app owning the n8n database.
NOCOBASE_DB_USERrequired
stringnocobaseBootstrap admin user for nocobase-db migrations and pgvector initialization.
NOCOBASE_DB_PASSWORDrequired
secret—Password for NOCOBASE_DB_USER.
NOCOBASE_APP_DB_USERrequired
stringnocobase_appNon-superuser, NOBYPASSRLS runtime role used by nocobase; must differ from NOCOBASE_DB_USER.
NOCOBASE_APP_DB_PASSWORDrequired
secret—Password for NOCOBASE_APP_DB_USER.
DX_PG_RLS_SESSION
booleantrueActivates the AsyncLocalStorage transaction bridge binding app.current_org and app.rls_bypass.
DATABASE_POOL_MAX
number20Maximum PostgreSQL connection pool size for the Fastify API service.
DX_DEFAULT_ORG_ID
string1Default organization ID fallback for single-org background workers.
Cryptographic Keys, PITR WAL, and Valkey 8.1 Variables
ParameterTypeDefaultDescription
NOCOBASE_APP_KEYrequired
secret—Signing secret mapped to APP_KEY for session JWTs; also acts as final fallback for PKI/Vault.
NOCOBASE_ENCRYPTION_FIELD_KEYrequired
secret—Field encryption secret mapped to ENCRYPTION_FIELD_KEY and AES-256-GCM wrapping of Ed25519 keys.
DX_VAULT_MASTER_KEY
secret—Dedicated AES-256-GCM master key for Connector Vault (takes precedence over ENCRYPTION_FIELD_KEY and APP_KEY).
LATTICE_TRACK_VERIFY_SECRET
secret—Dedicated HMAC-SHA256 key for verifying public ePOD QR proofs (/v/track/:code).
PG_ARCHIVE_COMMAND
string/bin/sh /etc/postgresql/pitr-archive.sh %p %fPostgreSQL archive_command archiving compressed WAL segments for Point-in-Time Recovery.
PITR_WAL_DIR
string/var/lib/postgresql/wal-archiveTarget directory for gzipped WAL segments (0700 directory permissions, umask 077).
PITR_WAL_RETENTION_DAYS
number7Retention window in days before pitr-archive.sh prunes older local .gz WAL files.
WALG_S3_PREFIX
string—Optional remote S3 prefix (s3://bucket/path) triggering wal-g wal-push when wal-g is available.
REDIS_PASSWORDrequired
secret—Authentication password for Valkey 8.1 across cache, Pub/Sub, OIDC state, and APISIX rate limits.
CACHE_DEFAULT_STORE
stringredisApplication cache backend adapter for NocoBase.
CACHE_REDIS_URL
stringredis://:${REDIS_PASSWORD}@redis:6379/0Valkey logical DB 0 URL for application caching.
PUBSUB_ADAPTER
stringredisPub/Sub transport adapter for cross-worker event fan-out.
PUBSUB_ADAPTER_REDIS_URL
stringredis://:${REDIS_PASSWORD}@redis:6379/1Valkey logical DB 1 URL hosting latticedx:surface-updates for real-time SSE.

Fail-Closed Cryptographic Key Enforcement

Under NODE_ENV=production, cryptographic subsystems reject development fallbacks:

  • pki-ledger.js requires either ENCRYPTION_FIELD_KEY or APP_KEY; omitting both throws PKI_MASTER_KEY_MISSING (HTTP 500).
  • connector-vault.js resolves DX_VAULT_MASTER_KEY || ENCRYPTION_FIELD_KEY || NOCOBASE_APP_KEY || APP_KEY; omitting all throws VAULT_MASTER_KEY_MISSING (HTTP 500). Set a dedicated DX_VAULT_MASTER_KEY in production so Connector Vault key rotation remains independent from Ed25519 private key wrapping in latticePkiKeys.

4. Keycloak OIDC, Enterprise Auth, and Action Bridge ​

@latticedx/plugin-enterprise-auth implements a 4-step OIDC PKCE S256 flow (start -> callback -> finish -> backchannelLogout), storing short-lived state: (300s), ticket: (60s), and revoked: (24h) keys in Valkey DB 2 while blocking privilege escalation during group-to-role mapping.

Keycloak 26.8.2, OIDC PKCE, and Action Bridge Variables
ParameterTypeDefaultDescription
KEYCLOAK_ADMIN_USERrequired
stringkc-adminBootstrap admin username for Keycloak.
KEYCLOAK_ADMIN_PASSWORDrequired
secret—Bootstrap admin password for Keycloak.
APISIX_OIDC_CLIENT_SECRETrequired
secret—Client secret for dx-gateway used by APISIX openid-connect and keycloak-config-cli.
APISIX_OIDC_DISCOVERY
stringhttps://${KEYCLOAK_DOMAIN}/realms/lattice/.well-known/openid-configurationOIDC discovery endpoint used by APISIX to fetch JWKS signing keys.
DX_NATIVE_AUTH_ISSUERrequired
stringhttps://${KEYCLOAK_DOMAIN}/realms/latticePublic OIDC issuer URL used for browser authorization redirects.
DX_NATIVE_AUTH_INTERNAL_ISSUERrequired
stringhttp://keycloak:8080/realms/latticeInternal Docker app-network OIDC issuer URL for server-to-Keycloak token exchange.
DX_NATIVE_AUTH_ORIGINrequired
stringhttps://${LATTICE_DOMAIN}Origin used to construct the OIDC redirect callback URI.
DX_NATIVE_AUTH_CLIENT_ID
stringdx-nativePublic PKCE S256 client identifier configured in the lattice realm.
DX_NATIVE_AUTH_CACHE_STORE
stringredisSession and PKCE state store backend for enterprise authentication.
DX_NATIVE_AUTH_SESSION_REDIS_URL
stringredis://:${REDIS_PASSWORD}@redis:6379/2Valkey logical DB 2 URL storing PKCE state, one-time tickets, and backchannel revocations.
DX_NATIVE_AUTH_GROUP_ROLE_MAP
json—JSON map from Keycloak groups to NocoBase roles (automatically skips ldx_admin, allowConfigure, and pm* roles).
DX_ALLOW_PUBLIC_SIGNUP
booleanfalseControls public self-registration endpoints (disabled by default).
DX_ENTERPRISE_DISABLE_SIGNUP
booleantrueStrictly disables local signup routes when enterprise SSO is enforced.
DX_BRIDGE_ISSUER
string—Public OIDC issuer URL for @latticedx/plugin-action-bridge.
DX_BRIDGE_INTERNAL_ISSUER
string—Internal OIDC issuer URL for @latticedx/plugin-action-bridge.
DX_BRIDGE_GATEWAY_URL
stringhttp://gateway:9080Internal APISIX gateway URL targeted by action-bridge.
DX_BRIDGE_CALLBACK_URL
string—Callback URL registered for action-bridge (/api/dxActions:callback).
NOCOBASE_INTERNAL_URL
stringhttp://127.0.0.1Internal loopback URL used by plugins invoking host NocoBase endpoints.

5. Core API, RustFS Object Storage, and ClamAV Scanner ​

Uploaded attachments pass through @dx/file-scanner (running with read_only: true) over the isolated scanner network to ClamAV 1.5.5 before objects are persisted to RustFS 1.0.6 on the data network.

Core API, File Scanner, ClamAV, and RustFS S3 Variables
ParameterTypeDefaultDescription
API_PORT
number4000Local HTTP port for the @dx/api Fastify service.
WORKER_PORT
number4001Local HTTP port for @dx/agent-worker.
API_URL
stringhttp://api:4000Internal base URL for @dx/api.
WORKER_URL
stringhttp://worker:4001Internal base URL for @dx/agent-worker.
API_RATE_LIMIT_MAX
number1000Fastify per-window request rate limit ceiling.
FILE_STORAGE_PROVIDER
enums3 (prod) / postgres (local)Object storage backend: s3 (RustFS) or postgres (local file storage).
FILE_STORAGE_ROOT
string/var/lib/latticedx/objectsFilesystem root path when using local object storage.
RUSTFS_ACCESS_KEYrequired
secret—Internal S3 access key for rustfs (mapped to S3_ACCESS_KEY_ID).
RUSTFS_SECRET_KEYrequired
secret—Internal S3 secret key for rustfs (mapped to S3_SECRET_ACCESS_KEY).
DX_NATIVE_FILES_URL
stringhttp://file-scanner:4010Internal scanner URL on the app network.
DX_NATIVE_FILES_INSTANCErequired
stringlatticedx-prodInstance identifier shared between nocobase and file-scanner.
DX_NATIVE_FILES_SECRETrequired
secret—Shared secret authenticating upload and scan requests to file-scanner.
DX_NATIVE_CLAMD_HOST
stringclamavHostname of the ClamAV daemon on the isolated scanner network.
DX_NATIVE_ATTACHMENT_SUBMIT_ORGANIZATION
string—Optional fallback organization assigned when native attachments omit an explicit org.
DX_UPLOAD_STALE_PENDING_MS
number900000Threshold in milliseconds before pending upload sessions are marked stale.

6. IIoT, Orion-LD, n8n, AI Studio, P.A.R.A. RAG, and Observability ​

Optional profiles and subsystem controls govern NGSI-LD outbox delivery, Mosquitto Dynamic Security, Node-RED 2-way downlinks, Stock n8n REST v1 integration, P.A.R.A. OCR/vector search, AI quotas, and OpenTelemetry / Prometheus / Grafana exports.

IIoT, FIWARE Orion-LD, n8n, and Outbox Variables
ParameterTypeDefaultDescription
ORION_MONGO_USERrequired
stringorion_rootRoot username for MongoDB 8.0 backing FIWARE Orion-LD.
ORION_MONGO_PASSWORDrequired
secret—Password for SCRAM-SHA-256 authentication on orion-mongo.
ORION_MONGO_VOLUME
string—Optional Docker volume override for recovered orion-mongo-data.
DX_NATIVE_CONTEXT_BROKER_URL
stringhttp://orion-ld:1026Internal Orion-LD Context Broker base URL.
DX_NATIVE_CONTEXT_AUTO_SYNC
booleantrueRuns the 10-second latticeContextOutbox drainer syncing NGSI-LD entities.
DX_OUTBOX_MAX_ATTEMPTS
number5Maximum retry attempts before outbox or event-bus rows move to failed or DLQ.
DX_OUTBOX_STALE_LOCK_MS
number120000Lock expiration window in milliseconds before stale outbox locks are reclaimed.
DX_EVENT_BUS_DRAINER
booleantrueEnables the 10-second CloudEvents 1.0 webhook delivery drainer.
DX_FLOW_DELAY_TICK_MS
number15000Polling interval in milliseconds for LatticeFlow v2 control.delay and cron schedules.
DX_SLA_CRON_ENABLED
booleantrueEnables background SLA breach detection and escalation.
DX_SLA_INTERVAL_MS
number60000Minimum interval in milliseconds between SLA evaluation sweeps.
MQTT_ADMIN_USER
stringldx_mqtt_adminMosquitto 2.0.21 Dynamic Security admin username (--profile iiot).
MQTT_ADMIN_PASSWORD
secret—Password for MQTT_ADMIN_USER.
MQTT_BRIDGE_USER
stringnodered_bridgeRestricted MQTT username injected into Node-RED flows_cred.json.
MQTT_BRIDGE_PASSWORD
secret—Password for MQTT_BRIDGE_USER.
DX_MQTT_BROKER_HOST
stringmosquittoInternal MQTT broker hostname on iiot-net.
DX_MQTT_BROKER_PORT
number1883Internal MQTT broker port.
DX_NODERED_COMMAND_URL
stringhttp://nodered:1880/twin/commandNode-RED HTTP downlink endpoint for Digital Twin setpoint commands.
DX_IIOT_INGEST_TOKEN
secret—Bearer token authenticating Node-RED telemetry and alarm ingest calls.
NODERED_CREDENTIAL_SECRET
secret—AES-256-CTR secret encrypting /data/flows_cred.json inside Node-RED.
NODERED_ADMIN_USER
stringnodered_adminAdmin UI username for Node-RED 4.0.9.
NODERED_ADMIN_PASS_HASH
secret—Bcrypt password hash for Node-RED admin UI authentication.
DX_ORION_HOST_ALLOWLIST
string—SSRF host allowlist for outbound Orion-LD broker calls.
DX_ORION_CALLBACK_HOST_ALLOWLIST
string—Allowlist of callback hostnames permitted in Orion-LD subscriptions.
DX_NODERED_HOST_ALLOWLIST
string—SSRF host allowlist for Digital Twin Node-RED downlink targets.
N8N_ENCRYPTION_KEY
secret—Credential encryption key for Stock n8n (--profile n8n).
N8N_URL
stringhttp://n8n:5678Internal base URL for Stock n8n.
N8N_WEBHOOK_BASE_URL
stringhttp://n8n:5678/webhookInternal webhook base URL for Stock n8n.
DX_N8N_API_URL
stringhttp://n8n:5678/api/v1n8n REST API v1 URL queried by plugin-dxos-studio.
DX_N8N_API_KEY
secret—Fallback X-N8N-API-KEY when credentials are not stored in Connector Vault.
DX_ALLOW_INTERNAL_CONNECTORS
booleanfalse (true in prod.yml)Permits Connector Vault to reach explicitly allowlisted internal Docker service hosts.
DX_INTERNAL_SERVICE_HOSTS
stringn8n,orion-ld,nodered,mosquittoComma-separated internal hostnames exempted from private-IP SSRF blocking.
DX_CONNECTOR_INTERNAL_ALLOWLIST
string—Additional internal connector host allowlist entries.
WORKFLOW_EVENT_URL
string—Optional fixed webhook destination for @dx/api outbox rows.
WORKFLOW_EVENT_TOKEN
secret—Bearer token sent to WORKFLOW_EVENT_URL.
AI Studio, P.A.R.A. Knowledge RAG, PDF, and Observability Variables
ParameterTypeDefaultDescription
AGENT_PROVIDER
stringopenai-compatibleDefault LLM provider adapter for AI services and CLI workers.
AGENT_BASE_URL
stringhttp://localhost:20128/v1OpenAI-compatible base URL for the LLM gateway.
AGENT_API_KEY
secret—Provider API key (also accepted as a fallback by DX_OCR_API_KEY).
AGENT_MODEL
stringcomboModel identifier used by @dx/agent-worker CLI invocations.
AGENT_ENGINE_URL
stringhttp://localhost:8080Trusted gateway origin for CLI agent runs.
AGENT_WORKER_TOKEN
secret—Short-lived JWT used by CLI agent worker invocations.
DXOS_AI_DAILY_ORG_CALL_LIMIT
number5000Daily AI tool invocation quota per organization.
DXOS_AI_DAILY_USER_CALL_LIMIT
number500Daily AI tool invocation quota per user.
DXOS_AI_DAILY_ORG_TOKEN_LIMIT
number5000000Daily token budget per organization.
DXOS_AI_DAILY_ORG_USD_LIMIT
number50Daily estimated USD spend cap per organization.
DXOS_MCP_INTERNAL_HTTP_ALLOWLIST
string—Comma-separated internal host allowlist for MCP IT/OT tool HTTP calls.
DX_EMBEDDING_URL
string—Embedding endpoint (or DXOS_EMBEDDING_URL) for pgvector HNSW hybrid RAG.
DX_EMBEDDING_DIM
number1536Vector dimension override (or DXOS_EMBEDDING_DIM, valid range 8..8192).
DX_OCR_ENDPOINT
string—Remote multimodal OCR endpoint for image-only PDFs (SSRF-guarded; external URLs require HTTPS).
DX_OCR_API_KEY
secret—API key sent to DX_OCR_ENDPOINT.
DX_OCR_TRUSTED_HOSTS
string—Internal OCR hostnames explicitly permitted without TLS.
DX_APPRISE_URL
string—Apprise gateway URL for omnichannel dxosNotify delivery.
DX_NOTIFICATION_WEBHOOK_URL
string—Default outbound webhook URL for system notifications.
DXOS_GOTENBERG_URL
stringhttp://gotenberg:3000 (--profile pdf)Gotenberg URL for sandboxed Unicode PDF voucher generation.
DXOS_PDF_FONT_PATH
string—Optional TrueType font path overriding the bundled Vietnamese PDF font.
DX_METRICS_TOKENrequired
secret—Bearer token authenticating Prometheus scrapes on GET /api/dxos:metrics before JWT parsing.
OTEL_EXPORTER_OTLP_ENDPOINT
stringhttp://otel-collector:4318OTLP/HTTP collector endpoint receiving API and OTel GenAI spans.
OTEL_SERVICE_NAME
stringlatticedx-nocobaseService name attribute attached to exported OpenTelemetry spans.
GRAFANA_ADMIN_USER
stringadminAdmin username for Grafana OSS 11.5.8 (--profile observability).
GRAFANA_ADMIN_PASSWORD
secret—Admin password for Grafana OSS 11.5.8.
LATTICE_SKIP_DEMO_SEED
string—Set to 1 to skip sample business records on clean database bootstrap while keeping 8 ldx_* roles and core schemas.

7. SSRF Guards and Runtime Health Verification ​

Server-side URL parsing enforces strict network boundaries on every outbound integration variable:

Variable / ScopeEnforcing ModuleSSRF & Credential Boundary
DX_OCR_ENDPOINTdocument-extractor.jsAccepts only http: or https:, rejects embedded credentials (OCR_ENDPOINT_CREDENTIALS_FORBIDDEN), blocks cloud metadata and CGNAT ranges (169.254.*, 100.64.0.0/10, fd00:ec2::254, metadata.google.internal, metadata.azure.com → OCR_ENDPOINT_SSRF_BLOCKED), and enforces https:// for any host outside localhost or DX_OCR_TRUSTED_HOSTS.
DX_ALLOW_INTERNAL_CONNECTORSconnector-vault.jsEvaluates both input URLs and resolved DNS records against loopback, RFC1918, and link-local ranges, permitting internal Docker hostnames only when listed in DX_INTERNAL_SERVICE_HOSTS or DX_CONNECTOR_INTERNAL_ALLOWLIST.
Loopback Fixture Values.env.exampleLocal strings such as local-demo-password, local-nocobase-password, local-redis-password, local-nocobase-app-key-public-fixture, and admin@nocobase.com are restricted to 127.0.0.1 development stacks and must never be reused on reachable networks.

Inspect live subsystem configuration flags (embeddingConfigured, ocrConfigured, DX_PG_RLS_SESSION, and plugin readiness) through these endpoints after startup:

GET/api/dxos:health
Public / Health
Reports platform readiness, mounted plugin status, and PostgreSQL / Valkey connectivity.
GET/api/latticePara:indexHealth
Bearer JWT | ldx_pat_*read
Inspects pgvector HNSW index health alongside embeddingConfigured and ocrConfigured runtime flags.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)