跳到主要内容

Environment Variables Reference

Complete reference for all available environment variables in UnderControl backend configuration.

Core Configuration

Environment Settings

VariableDescriptionDefaultRequired
ENVIRONMENTDeployment environment (development, production)developmentNo
PORTBackend server port4000No
LOG_LEVELLogging level (debug, info, warn, error)infoNo

Data Directory

VariableDescriptionDefaultRequired
UD_DATA_PATHBase path for all data files (database, uploads, blob storage)./dataNo

Database Configuration

Database Type

VariableDescriptionDefaultRequired
DATABASE_TYPEDatabase type: sqlite or postgressqliteNo
DATABASE_URLFull database connection string (overrides individual settings)-No

PostgreSQL Configuration

Required when DATABASE_TYPE=postgres:

VariableDescriptionDefaultRequired
POSTGRES_HOSTPostgreSQL server hostnamelocalhostYes*
POSTGRES_PORTPostgreSQL server port5432No
POSTGRES_USERPostgreSQL usernamepostgresYes*
POSTGRES_PASSWORDPostgreSQL password-Yes*
POSTGRES_DATABASEPostgreSQL database nameundercontrolYes*
POSTGRES_SSL_MODESSL mode (disable, require, verify-ca, verify-full)disableNo

* Required when using PostgreSQL

PostgreSQL Connection Pool

Optional tuning parameters:

VariableDescriptionDefault
POSTGRES_MAX_OPEN_CONNSMaximum number of open connections25
POSTGRES_MAX_IDLE_CONNSMaximum number of idle connections5
POSTGRES_CONN_MAX_LIFETIMEMaximum connection lifetime (seconds)300
POSTGRES_CONN_MAX_IDLE_TIMEMaximum idle time (seconds)60

Authentication

JWT Configuration

VariableDescriptionDefaultRequired
JWT_SECRETSecret key for JWT token signing-Yes
JWT_EXPIRATION_MINUTESJWT token expiration time in minutes60No
Security Warning

You MUST change JWT_SECRET to a secure random value in production:

openssl rand -base64 32

File Storage

Upload Configuration

VariableDescriptionDefault
MAX_FILE_SIZEMaximum file size in bytes10485760 (10MB)

Blob Storage

UnderControl automatically selects storage provider:

  • If S3 is enabled and configured → Uses S3-compatible storage
  • Otherwise → Uses LocalFS (no configuration needed)

S3-Compatible Storage

For Cloudflare R2, AWS S3, MinIO, or other S3-compatible services:

VariableDescriptionRequired
S3_ENABLEDEnable S3 storage (true/false)Yes
S3_ACCESS_KEY_IDS3 access key IDYes*
S3_SECRET_ACCESS_KEYS3 secret access keyYes*
S3_BUCKETS3 bucket nameYes*
S3_ENDPOINTS3 endpoint URLYes*
S3_REGIONS3 region (use auto for Cloudflare R2)No
S3_FORCE_PATH_STYLEUse path-style URLs (required for R2/MinIO)No

* Required when S3_ENABLED=true

Example (Cloudflare R2):

S3_ENABLED=true
S3_ACCESS_KEY_ID=your-access-key-id
S3_SECRET_ACCESS_KEY=your-secret-access-key
S3_BUCKET=your-bucket-name
S3_ENDPOINT=https://account-id.r2.cloudflarestorage.com
S3_REGION=auto
S3_FORCE_PATH_STYLE=true

LocalFS Storage

Automatic fallback when S3 is not enabled. Optional configuration:

VariableDescriptionWhen Needed
LOCALFS_BASE_URLBase URL for presigned URLsBehind reverse proxy or custom domain

Example:

LOCALFS_BASE_URL=https://api.example.com

External Services (Optional)

OpenAI Integration

For AI features (expense extraction, todolist generation):

VariableDescriptionDefault
OPENAI_API_KEYOpenAI API key-
OPENAI_MODELModel to usegpt-4o-mini
OPENAI_BASE_URLAPI base URLhttps://api.openai.com/v1
OPENAI_MAX_TOKENSMaximum tokens per request1000
OPENAI_TEMPERATURETemperature (0-1)0.7
OPENAI_ORG_IDOrganization ID-

Azure Vision

Optional OCR service:

VariableDescription
AZURE_VISION_KEYAzure Vision API key
AZURE_VISION_URLAzure Vision endpoint URL

Slack Notifications

For backup notifications:

VariableDescription
SLACK_WEBHOOK_URLSlack webhook URL

Monitoring & Observability

OpenTelemetry Configuration

VariableDescriptionDefault
OTEL_ENABLEDEnable OpenTelemetrytrue
OTEL_SERVICE_NAMEService name for telemetryAuto-generated from ENVIRONMENT

For services like OneUptime:

VariableDescription
OTEL_EXPORTER_OTLP_ENDPOINTUnified OTLP endpoint URL
OTEL_EXPORTER_OTLP_HEADERSHeaders (e.g., authentication tokens)

Example:

OTEL_EXPORTER_OTLP_ENDPOINT=https://oneuptime.com/otlp
OTEL_EXPORTER_OTLP_HEADERS=x-oneuptime-token=your-token-here

Legacy Individual Endpoints

VariableDescription
OTEL_TRACES_ENDPOINTTraces endpoint URL
OTEL_METRICS_ENDPOINTMetrics endpoint URL
OTEL_LOGS_ENDPOINTLogs endpoint URL

Cron Jobs

Visitor Data Cleanup

VariableDescriptionDefault
CRON_ENABLEDEnable cron jobstrue
VISITOR_CLEANUP_ENABLEDEnable visitor data cleanuptrue
VISITOR_RETENTION_DAYSDays to retain visitor data3
VISITOR_CLEANUP_SCHEDULECron schedule0 0 * * * (daily at midnight)

Backup Configuration

VariableDescriptionDefault
BACKUP_ENABLEDEnable automated backupsfalse
BACKUP_SCHEDULECron schedule0 0 * * * (daily at midnight)
BACKUP_DATA_PATHPath to data directory to backupValue of UD_DATA_PATH
BACKUP_DIRDirectory to store backups./backups
BACKUP_RETENTION_DAYSDays to keep backups30

CORS Configuration

VariableDescription
CORS_ALLOWED_ORIGINSComma-separated list of allowed origins

Examples:

Development:

CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:12000

Production:

CORS_ALLOWED_ORIGINS=https://app.example.com
Security Warning

Do NOT use * in production - always specify explicit allowed origins.

Admin User

Default Admin Account

Created automatically on first startup:

VariableDescriptionDefault
ADMIN_USERNAMEDefault admin usernameadmin@oatnil.com
ADMIN_PASSWORDDefault admin passwordadmin123
Security Warning

Change these credentials immediately in production!

Environment File Examples

Minimal Configuration (SQLite + LocalFS)

# Basic Settings
PORT=8080
UD_DATA_PATH=/data

# JWT Authentication (CHANGE THIS!)
JWT_SECRET=your-super-secret-jwt-key-change-this

# CORS
CORS_ALLOWED_ORIGINS=http://localhost:3000

# Storage
S3_ENABLED=false

Production Configuration (PostgreSQL + S3)

# Environment
ENVIRONMENT=production
PORT=8080
LOG_LEVEL=info

# Data Path
UD_DATA_PATH=/data

# Database
DATABASE_TYPE=postgres
POSTGRES_HOST=db.example.com
POSTGRES_PORT=5432
POSTGRES_USER=undercontrol
POSTGRES_PASSWORD=secure-db-password
POSTGRES_DATABASE=undercontrol
POSTGRES_SSL_MODE=require

# JWT Authentication
JWT_SECRET=your-generated-secure-random-jwt-secret

# CORS
CORS_ALLOWED_ORIGINS=https://app.example.com

# S3 Storage (Cloudflare R2)
S3_ENABLED=true
S3_ACCESS_KEY_ID=your-r2-access-key-id
S3_SECRET_ACCESS_KEY=your-r2-secret-key
S3_BUCKET=undercontrol-production
S3_ENDPOINT=https://account-id.r2.cloudflarestorage.com
S3_REGION=auto
S3_FORCE_PATH_STYLE=true

# OpenAI (Optional)
OPENAI_API_KEY=sk-your-openai-api-key
OPENAI_MODEL=gpt-4o-mini

# Monitoring
OTEL_ENABLED=true
OTEL_EXPORTER_OTLP_ENDPOINT=https://oneuptime.com/otlp
OTEL_EXPORTER_OTLP_HEADERS=x-oneuptime-token=your-token

# Backups
BACKUP_ENABLED=true
BACKUP_SCHEDULE="0 2 * * *" # 2 AM daily
BACKUP_RETENTION_DAYS=30

# Admin
ADMIN_USERNAME=admin@yourcompany.com
ADMIN_PASSWORD=change-me-on-first-login