title: Navius Environment Variables Reference description: Comprehensive reference of environment variables for configuring Navius applications category: reference tags:

  • configuration
  • environment-variables
  • settings related:
  • ../architecture/principles.md
  • ../../guides/deployment/production-deployment.md
  • ../../guides/deployment/cloud-deployment.md last_updated: March 27, 2025 version: 1.0

Navius Environment Variables Reference

Overview

This reference document provides a comprehensive list of all environment variables supported by the Navius framework. Environment variables are used to configure various aspects of the application without changing code or configuration files, making them ideal for deployment across different environments.

Core Settings

VariableDescriptionDefaultExample
RUN_ENVApplication environmentdevelopmentproduction
PORTHTTP server port30008080
HOSTHTTP server host127.0.0.10.0.0.0
LOG_LEVELLogging verbosity levelinfodebug
LOG_FORMATLog output formattextjson
CONFIG_PATHPath to configuration directory./config/etc/navius/config
RUST_BACKTRACEEnable backtrace on errors01
RUST_LOGDetailed logging configuration-navius=debug,warn

Database Configuration

VariableDescriptionDefaultExample
DATABASE_URLDatabase connection string-postgres://user:pass@localhost/dbname
DATABASE_POOL_SIZEMax database connections520
DATABASE_TIMEOUT_SECONDSQuery timeout in seconds3010
DATABASE_CONNECT_TIMEOUT_SECONDSConnection timeout in seconds53
DATABASE_IDLE_TIMEOUT_SECONDSIdle connection timeout300600
DATABASE_MAX_LIFETIME_SECONDSMax connection lifetime18003600
DATABASE_SSL_MODESSL connection modepreferrequire
RUN_MIGRATIONSAuto-run migrations on startupfalsetrue

Cache Configuration

VariableDescriptionDefaultExample
REDIS_URLRedis connection URL-redis://localhost:6379
REDIS_POOL_SIZEMax Redis connections510
REDIS_TIMEOUT_SECONDSRedis command timeout53
CACHE_TTL_SECONDSDefault cache TTL3600300
CACHE_PREFIXCache key prefixnavius:myapp:prod:
CACHE_ENABLEDEnable cachingtruefalse

Security Settings

VariableDescriptionDefaultExample
JWT_SECRETSecret for JWT tokens-your-jwt-secret-key
JWT_EXPIRATION_SECONDSJWT token expiration864003600
CORS_ALLOWED_ORIGINSAllowed CORS origins*https://example.com,https://app.example.com
CORS_ALLOWED_METHODSAllowed CORS methodsGET,POST,PUT,DELETEGET,POST
CORS_ALLOWED_HEADERSAllowed CORS headersContent-Type,AuthorizationX-API-Key,Authorization
CORS_MAX_AGE_SECONDSCORS preflight cache time864003600
API_KEYGlobal API key for auth-your-api-key
TLS_CERT_PATHPath to TLS certificate-/etc/certs/server.crt
TLS_KEY_PATHPath to TLS private key-/etc/certs/server.key
ENABLE_TLSEnable TLS encryptionfalsetrue

HTTP Server Settings

VariableDescriptionDefaultExample
REQUEST_TIMEOUT_SECONDSHTTP request timeout3060
REQUEST_BODY_LIMITMax request body size1MB10MB
ENABLE_COMPRESSIONEnable response compressiontruefalse
KEEP_ALIVE_SECONDSKeep-alive connection timeout75120
MAX_CONNECTIONSMax concurrent connections102410000
WORKERSNumber of worker threads(cores * 2)8
ENABLE_HEALTH_CHECKEnable /health endpointtruefalse
GRACEFUL_SHUTDOWN_SECONDSGraceful shutdown period3010

API Settings

VariableDescriptionDefaultExample
API_VERSIONDefault API versionv1v2
ENABLE_DOCSEnable API documentationtruefalse
DOCS_URL_PATHPath to API docs/docs/api/docs
RATE_LIMIT_ENABLEDEnable rate limitingfalsetrue
RATE_LIMIT_REQUESTSMax requests per window1001000
RATE_LIMIT_WINDOW_SECONDSRate limit time window603600
API_BASE_PATHBase path for all APIs/api/api/v1

Monitoring and Telemetry

VariableDescriptionDefaultExample
ENABLE_METRICSEnable Prometheus metricstruefalse
METRICS_PATHMetrics endpoint path/metrics/actuator/metrics
TRACING_ENABLEDEnable OpenTelemetry tracingfalsetrue
JAEGER_ENDPOINTJaeger collector endpoint-http://jaeger:14268/api/traces
OTLP_ENDPOINTOTLP collector endpoint-http://collector:4317
SERVICE_NAMEService name for telemetrynaviususer-service
LOG_REQUEST_HEADERSLog HTTP request headersfalsetrue
HEALTH_CHECK_PATHHealth check endpoint path/health/actuator/health

Integration Settings

VariableDescriptionDefaultExample
EMAIL_SMTP_HOSTSMTP server host-smtp.example.com
EMAIL_SMTP_PORTSMTP server port25587
EMAIL_SMTP_USERNAMESMTP authentication user-[email protected]
EMAIL_SMTP_PASSWORDSMTP authentication password-password
EMAIL_DEFAULT_FROMDefault sender address-[email protected]
AWS_ACCESS_KEY_IDAWS access key-AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEYAWS secret key-wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_REGIONAWS regionus-east-1eu-west-1
S3_BUCKETS3 bucket name-my-app-uploads
S3_URL_EXPIRATION_SECONDSS3 presigned URL expiration3600300

Resource Limits

VariableDescriptionDefaultExample
MEMORY_LIMITMemory limit in MB-512
CPU_LIMITCPU limit (percentage)-80
TOKIO_WORKER_THREADSTokio runtime worker threads(cores)8
BLOCKING_THREADSTokio blocking thread pool size(cores * 4)32
MAX_TASK_BACKLOGMax queued tasks100005000

Feature Flags

VariableDescriptionDefaultExample
FEATURE_ADVANCED_SEARCHEnable advanced searchfalsetrue
FEATURE_FILE_UPLOADSEnable file uploadstruefalse
FEATURE_WEBSOCKETSEnable WebSocket supportfalsetrue
FEATURE_BATCH_PROCESSINGEnable batch processingfalsetrue
FEATURE_NOTIFICATIONSEnable notificationstruefalse

Using Environment Variables

Environment variables can be set in various ways:

1. In development (.env file):

# .env
DATABASE_URL=postgres://localhost/navius_dev
LOG_LEVEL=debug
FEATURE_ADVANCED_SEARCH=true

2. In shell:

export DATABASE_URL=postgres://localhost/navius_dev
export LOG_LEVEL=debug
./run_dev.sh

3. In Docker:

docker run -e DATABASE_URL=postgres://db/navius -e LOG_LEVEL=info navius

4. In Kubernetes:

env:
  - name: DATABASE_URL
    valueFrom:
      secretKeyRef:
        name: db-credentials
        key: url
  - name: LOG_LEVEL
    value: "info"

Precedence

Environment variables are loaded in this order (later sources override earlier ones):

  1. Default values
  2. Configuration files (config/{environment}.toml)
  3. .env file
  4. Environment variables
  5. Command line arguments