Skip to main content

Environment Variables

Tianji supports various environment variables to customize its behavior. You can configure these variables in your docker compose env field or through your deployment environment.

Basic Configuration​

VariableDescriptionDefaultExample
PORTServer port123453000
JWT_SECRETSecret for JWT tokensRandom secret on each startupreplace-me-with-a-random-string
ALLOW_REGISTEREnable user registrationfalsetrue
ALLOW_OPENAPIEnable OpenAPI accesstruefalse
WEBSITE_IDWebsite identifier-your-website-id
DISABLE_AUTO_CLEARDisable automatic data cleanupfalsetrue
AUDIT_LOG_RETENTION_DAYSNumber of days to retain audit logs3090
DISABLE_ACCESS_LOGSDisable access logsfalsetrue
DB_DEBUGEnable database debuggingfalsetrue
ALPHA_MODEEnable alpha featuresfalsetrue
ENABLE_FUNCTION_WORKEREnable function workerfalsetrue
WORKER_EXECUTION_REQUEST_PAYLOAD_DISABLED_WORKER_IDSComma-separated worker IDs whose execution request payloads are not persisted. Payloads are still passed to worker code.-worker-id-1,worker-id-2
REGISTER_AUTO_JOIN_WORKSPACE_IDAuto-join workspace ID for new users-workspace-id-123

If JWT_SECRET is empty or set to replace-me-with-a-random-string, Tianji generates a random secret on each startup. For production, generate a secret with openssl rand -hex 32, store it in your deployment configuration, and use the same value across replicas to keep tokens valid across restarts. Deployments using older example values must replace them with a generated secret.

Cache Configuration​

VariableDescriptionDefaultExample
CACHE_MEMORY_ONLYUse memory-only cachingfalsetrue
REDIS_URLRedis connection URL for caching and shared authentication rate limits-redis://localhost:6379

Authentication rate limits​

Authentication rate limiting is enabled by default (DISABLE_AUTH_RATE=false) and requires REDIS_URL. Set DISABLE_AUTH_RATE=true to disable it without affecting Redis caching. When active, atomic, IP-based limits are shared by all replicas, Auth.js, tRPC (including each operation in a batch), and OpenAPI. Limits count all attempts, including successful requests. They use fixed windows starting with the first attempt and expire automatically in Redis.

OperationRequests per IPWindow
Password login1015 minutes
Registration51 hour
Password change515 minutes
Token login, email verification, invitation lookup/acceptance, and OAuth sign-in/callback (shared quota)3015 minutes
Sign-in emails and workspace invitations (shared quota)515 minutes

Exceeding a limit returns 429 Too Many Requests with the remaining wait in the error message. Auth.js responses also include Retry-After. Workspace invitations count even when an existing user is added without sending email. Session reads, CSRF token requests, and sign-out are unaffected.

Without REDIS_URL, these limits are disabled. CACHE_MEMORY_ONLY does not disable rate limiting when REDIS_URL is set. If configured Redis is unavailable, protected operations return 503 Service Unavailable instead of bypassing the limits.

By default, rate limits use the socket's remote IP and ignore forwarded headers. Behind a reverse proxy, set CLIENT_IP_HEADER to a header containing one client IP, such as x-real-ip or cf-connecting-ip. The proxy must overwrite this header, and direct access to Tianji must be restricted to trusted proxies. Missing or invalid header values fall back to the socket IP. Without this configuration, users behind the same proxy share its quota. IP addresses are hashed in Redis keys; no passwords, tokens, or email addresses are stored by the limiter.

Authentication​

VariableDescriptionDefaultExample
DISABLE_ACCOUNTDisable account-based authenticationfalsetrue
AUTH_SECRETAuthentication secretMD5 of JWT secretyour-auth-secret
DISABLE_AUTH_RATEDisable Redis-backed authentication and email rate limitsfalsetrue
AUTH_RESTRICT_EMAILRestrict registration to specific email domains-@example.com
AUTH_USE_SECURE_COOKIESUse secure cookies for authenticationfalsetrue

Email Authentication and Email Invitation​

VariableDescriptionDefaultExample
EMAIL_SERVERSMTP server for email-smtp://user:pass@smtp.example.com:587
EMAIL_FROMEmail sender address-noreply@example.com

GitHub Authentication​

VariableDescriptionDefaultExample
AUTH_GITHUB_IDGitHub OAuth client ID-your-github-client-id
AUTH_GITHUB_SECRETGitHub OAuth client secret-your-github-client-secret

Google Authentication​

VariableDescriptionDefaultExample
AUTH_GOOGLE_IDGoogle OAuth client ID-your-google-client-id
AUTH_GOOGLE_SECRETGoogle OAuth client secret-your-google-client-secret

Custom OAuth/OIDC Authentication​

VariableDescriptionDefaultExample
AUTH_CUSTOM_IDCustom OAuth/OIDC client ID-your-custom-client-id
AUTH_CUSTOM_SECRETCustom OAuth/OIDC client secret-your-custom-client-secret
AUTH_CUSTOM_NAMECustom provider nameCustomEnterprise SSO
AUTH_CUSTOM_TYPEAuthentication typeoidcoauth
AUTH_CUSTOM_ISSUEROIDC issuer URL-https://auth.example.com

AI Features​

VariableDescriptionDefaultExample
SHARED_OPENAI_API_KEYOpenAI API key-your-openai-api-key
SHARED_OPENAI_BASE_URLCustom OpenAI API URL-https://api.openai.com/v1
SHARED_OPENAI_MODEL_NAMEOpenAI model to usegpt-4ogpt-3.5-turbo
SHARED_OPENAI_TOKEN_CALC_CONCURRENCYToken calculation concurrency510
DEBUG_AI_FEATUREDebug AI featuresfalsetrue

ClickHouse Configuration​

VariableDescriptionDefaultExample
CLICKHOUSE_URLClickHouse database URL-http://localhost:8123
CLICKHOUSE_USERClickHouse username-default
CLICKHOUSE_PASSWORDClickHouse password-your-password
CLICKHOUSE_DATABASEClickHouse database name-tianji
CLICKHOUSE_DEBUGEnable ClickHouse debuggingfalsetrue
CLICKHOUSE_DISABLE_SYNCDisable ClickHouse synchronizationfalsetrue
CLICKHOUSE_SYNC_BATCH_SIZESynchronization batch size100005000
CLICKHOUSE_ENABLE_FALLBACKEnable ClickHouse fallbacktruefalse
CLICKHOUSE_HEALTH_CHECK_INTERVALHealth check interval (ms)3000060000
CLICKHOUSE_MAX_CONSECUTIVE_FAILURESMaximum consecutive failures35
CLICKHOUSE_RETRY_INTERVALRetry interval (ms)500010000

Billing System (LemonSqueezy)​

VariableDescriptionDefaultExample
ENABLE_BILLINGEnable billing functionalityfalsetrue
LEMON_SQUEEZY_SIGNATURE_SECRETLemonSqueezy webhook signature secret-your-signature-secret
LEMON_SQUEEZY_API_KEYLemonSqueezy API key-your-api-key
LEMON_SQUEEZY_STORE_IDLemonSqueezy store ID-your-store-id
LEMON_SQUEEZY_SUBSCRIPTION_FREE_IDFree tier subscription variant ID-free-variant-id
LEMON_SQUEEZY_SUBSCRIPTION_PRO_IDPro tier subscription variant ID-pro-variant-id
LEMON_SQUEEZY_SUBSCRIPTION_TEAM_IDTeam tier subscription variant ID-team-variant-id

Sandbox Configuration​

VariableDescriptionDefaultExample
USE_VM2Use VM2 for sandbox executionfalsetrue
SANDBOX_MEMORY_LIMITMemory limit for sandbox (MB)1632
PUPPETEER_EXECUTABLE_PATHCustom path to Puppeteer executable-/usr/bin/chromium

Maps Integration​

VariableDescriptionDefaultExample
AMAP_TOKENAMap (Gaode) API token-your-amap-token
MAPBOX_TOKENMapbox API token-your-mapbox-token

Telemetry​

VariableDescriptionDefaultExample
DISABLE_ANONYMOUS_TELEMETRYDisable anonymous telemetryfalsetrue
CUSTOM_TRACKER_SCRIPT_NAMECustom tracker script name-custom-tracker.js

Setting Environment Variables​

You can set these environment variables in different ways:

  1. Set them directly in your deployment environment (Docker, Kubernetes, etc.)

  2. For Docker deployments, you can use environment variables in your docker-compose.yml:

services:
tianji:
image: moonrailgun/tianji:latest
environment:
- PORT=3000
- ALLOW_REGISTER=true

Boolean Values​

For boolean environment variables, you can use either "1" or "true" to enable the feature, and either omit the variable or set it to any other value to disable it.