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
| Variable | Description | Default | Example |
|---|
PORT | Server port | 12345 | 3000 |
JWT_SECRET | Secret for JWT tokens | Random secret on each startup | replace-me-with-a-random-string |
ALLOW_REGISTER | Enable user registration | false | true |
ALLOW_OPENAPI | Enable OpenAPI access | true | false |
WEBSITE_ID | Website identifier | - | your-website-id |
DISABLE_AUTO_CLEAR | Disable automatic data cleanup | false | true |
AUDIT_LOG_RETENTION_DAYS | Number of days to retain audit logs | 30 | 90 |
DISABLE_ACCESS_LOGS | Disable access logs | false | true |
DB_DEBUG | Enable database debugging | false | true |
ALPHA_MODE | Enable alpha features | false | true |
ENABLE_FUNCTION_WORKER | Enable function worker | false | true |
WORKER_EXECUTION_REQUEST_PAYLOAD_DISABLED_WORKER_IDS | Comma-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_ID | Auto-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
| Variable | Description | Default | Example |
|---|
CACHE_MEMORY_ONLY | Use memory-only caching | false | true |
REDIS_URL | Redis 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.
| Operation | Requests per IP | Window |
|---|
| Password login | 10 | 15 minutes |
| Registration | 5 | 1 hour |
| Password change | 5 | 15 minutes |
| Token login, email verification, invitation lookup/acceptance, and OAuth sign-in/callback (shared quota) | 30 | 15 minutes |
| Sign-in emails and workspace invitations (shared quota) | 5 | 15 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
| Variable | Description | Default | Example |
|---|
DISABLE_ACCOUNT | Disable account-based authentication | false | true |
AUTH_SECRET | Authentication secret | MD5 of JWT secret | your-auth-secret |
DISABLE_AUTH_RATE | Disable Redis-backed authentication and email rate limits | false | true |
AUTH_RESTRICT_EMAIL | Restrict registration to specific email domains | - | @example.com |
AUTH_USE_SECURE_COOKIES | Use secure cookies for authentication | false | true |
Email Authentication and Email Invitation
| Variable | Description | Default | Example |
|---|
EMAIL_SERVER | SMTP server for email | - | smtp://user:pass@smtp.example.com:587 |
EMAIL_FROM | Email sender address | - | noreply@example.com |
GitHub Authentication
| Variable | Description | Default | Example |
|---|
AUTH_GITHUB_ID | GitHub OAuth client ID | - | your-github-client-id |
AUTH_GITHUB_SECRET | GitHub OAuth client secret | - | your-github-client-secret |
Google Authentication
| Variable | Description | Default | Example |
|---|
AUTH_GOOGLE_ID | Google OAuth client ID | - | your-google-client-id |
AUTH_GOOGLE_SECRET | Google OAuth client secret | - | your-google-client-secret |
Custom OAuth/OIDC Authentication
| Variable | Description | Default | Example |
|---|
AUTH_CUSTOM_ID | Custom OAuth/OIDC client ID | - | your-custom-client-id |
AUTH_CUSTOM_SECRET | Custom OAuth/OIDC client secret | - | your-custom-client-secret |
AUTH_CUSTOM_NAME | Custom provider name | Custom | Enterprise SSO |
AUTH_CUSTOM_TYPE | Authentication type | oidc | oauth |
AUTH_CUSTOM_ISSUER | OIDC issuer URL | - | https://auth.example.com |
AI Features
| Variable | Description | Default | Example |
|---|
SHARED_OPENAI_API_KEY | OpenAI API key | - | your-openai-api-key |
SHARED_OPENAI_BASE_URL | Custom OpenAI API URL | - | https://api.openai.com/v1 |
SHARED_OPENAI_MODEL_NAME | OpenAI model to use | gpt-4o | gpt-3.5-turbo |
SHARED_OPENAI_TOKEN_CALC_CONCURRENCY | Token calculation concurrency | 5 | 10 |
DEBUG_AI_FEATURE | Debug AI features | false | true |
ClickHouse Configuration
| Variable | Description | Default | Example |
|---|
CLICKHOUSE_URL | ClickHouse database URL | - | http://localhost:8123 |
CLICKHOUSE_USER | ClickHouse username | - | default |
CLICKHOUSE_PASSWORD | ClickHouse password | - | your-password |
CLICKHOUSE_DATABASE | ClickHouse database name | - | tianji |
CLICKHOUSE_DEBUG | Enable ClickHouse debugging | false | true |
CLICKHOUSE_DISABLE_SYNC | Disable ClickHouse synchronization | false | true |
CLICKHOUSE_SYNC_BATCH_SIZE | Synchronization batch size | 10000 | 5000 |
CLICKHOUSE_ENABLE_FALLBACK | Enable ClickHouse fallback | true | false |
CLICKHOUSE_HEALTH_CHECK_INTERVAL | Health check interval (ms) | 30000 | 60000 |
CLICKHOUSE_MAX_CONSECUTIVE_FAILURES | Maximum consecutive failures | 3 | 5 |
CLICKHOUSE_RETRY_INTERVAL | Retry interval (ms) | 5000 | 10000 |
Billing System (LemonSqueezy)
| Variable | Description | Default | Example |
|---|
ENABLE_BILLING | Enable billing functionality | false | true |
LEMON_SQUEEZY_SIGNATURE_SECRET | LemonSqueezy webhook signature secret | - | your-signature-secret |
LEMON_SQUEEZY_API_KEY | LemonSqueezy API key | - | your-api-key |
LEMON_SQUEEZY_STORE_ID | LemonSqueezy store ID | - | your-store-id |
LEMON_SQUEEZY_SUBSCRIPTION_FREE_ID | Free tier subscription variant ID | - | free-variant-id |
LEMON_SQUEEZY_SUBSCRIPTION_PRO_ID | Pro tier subscription variant ID | - | pro-variant-id |
LEMON_SQUEEZY_SUBSCRIPTION_TEAM_ID | Team tier subscription variant ID | - | team-variant-id |
Sandbox Configuration
| Variable | Description | Default | Example |
|---|
USE_VM2 | Use VM2 for sandbox execution | false | true |
SANDBOX_MEMORY_LIMIT | Memory limit for sandbox (MB) | 16 | 32 |
PUPPETEER_EXECUTABLE_PATH | Custom path to Puppeteer executable | - | /usr/bin/chromium |
Maps Integration
| Variable | Description | Default | Example |
|---|
AMAP_TOKEN | AMap (Gaode) API token | - | your-amap-token |
MAPBOX_TOKEN | Mapbox API token | - | your-mapbox-token |
Telemetry
| Variable | Description | Default | Example |
|---|
DISABLE_ANONYMOUS_TELEMETRY | Disable anonymous telemetry | false | true |
CUSTOM_TRACKER_SCRIPT_NAME | Custom tracker script name | - | custom-tracker.js |
Setting Environment Variables
You can set these environment variables in different ways:
-
Set them directly in your deployment environment (Docker, Kubernetes, etc.)
-
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.