Backend Environment Variables

Backend and Worker Environment Variables #

NewsFeed’s backend services (API and worker) are configured using environment variables. This page documents all available environment variables and their purpose.

Configuration Categories #

The backend environment variables are organized into several categories:

  1. Core Configuration: Basic settings for the backend services
  2. Database Configuration: PostgreSQL connection settings
  3. Redis Configuration: Redis connection settings
  4. FreshRSS Configuration: Settings for the FreshRSS integration
  5. Worker Configuration: Settings for the Celery worker and tasks
  6. Authentication Configuration: Casdoor authentication settings

Core Configuration #

VariableDescriptionDefault Value
BACKEND_DEBUGEnable debug mode for the backend"false"
TIMEZONETimezone for date/time operations"UTC"
THUMBNAIL_DIRDirectory to store article thumbnails"/thumbnails"

Database Configuration #

VariableDescriptionDefault Value
POSTGRES_USERPostgreSQL username"postgres"
POSTGRES_PASSWORDPostgreSQL password"postgres"
POSTGRES_DBPostgreSQL database name"newsfeed"
POSTGRES_HOSTPostgreSQL host address"db"
POSTGRES_PORTPostgreSQL port"5432"

Redis Configuration #

VariableDescriptionDefault Value
REDIS_URLRedis connection URL"redis://redis:6379/0"

FreshRSS Configuration #

FreshRSS GReader API #

VariableDescriptionDefault Value
FRESHRSS_GREADER_API_URLFreshRSS GReader API URLNone
FRESHRSS_GREADER_API_USERFreshRSS GReader API usernameNone
FRESHRSS_GREADER_API_PASSWORDFreshRSS GReader API passwordNone

FreshRSS Python API #

VariableDescriptionDefault Value
FRESHRSS_PYTHON_API_HOSTFreshRSS Python API hostNone
FRESHRSS_PYTHON_API_USERNAMEFreshRSS Python API usernameNone
FRESHRSS_PYTHON_API_PASSWORDFreshRSS Python API passwordNone
FRESHRSS_PYTHON_API_VERIFY_SSLVerify SSL certificates"true"

FreshRSS Proxy API #

VariableDescriptionDefault Value
FRESHRSS_PROXY_API_URLFreshRSS Proxy API URLNone
FRESHRSS_PROXY_API_KEYFreshRSS Proxy API keyNone

Worker Configuration #

Task Scheduling #

VariableDescriptionDefault Value
WORKER_PROCESS_ARTICLES_INTERVALHow often to process articles (minutes)15
WORKER_PURGE_OLD_ARTICLES_INTERVALHow often to purge old articles (minutes)1440 (24 hours)
WORKER_ENRICH_ARTICLES_INTERVALHow often to enrich articles (minutes)60 (1 hour)

Article Fetching and Retention #

VariableDescriptionDefault Value
WORKER_FRESHRSS_FETCH_LIMITMaximum articles to fetch per batch100
WORKER_CONCURRENT_FRESHRSS_FETCH_TASKSNumber of concurrent fetch tasks1
WORKER_FRESHRSS_FETCH_DAYSNumber of days to fetch articles from3
WORKER_FRESHRSS_PURGE_NUM_DAYS_TO_KEEPNumber of days to keep articles7

Worker Performance #

VariableDescriptionDefault Value
WORKER_TASK_TIME_LIMITMaximum task runtime (seconds)300 (5 minutes)
WORKER_SOFT_TIME_LIMITSoft time limit for tasks (seconds)240 (4 minutes)
WORKER_MAX_TASKS_PER_CHILDTasks per worker before replacement100
WORKER_MAX_MEMORY_PER_CHILDMemory limit per worker (KB)200000 (200MB)
WORKER_PREFETCH_MULTIPLIERTasks to prefetch per worker1

AI Configuration #

VariableDescriptionDefault Value
OLLAMA_URLURL of the Ollama server"http://ollama:11434"
OLLAMA_MODELAI model to use for categorization"LLAMA3.2:3B"

Authentication Configuration #

VariableDescriptionDefault Value
CASDOOR_ENDPOINTCasdoor server URL"http://casdoor:8000"
CASDOOR_CLIENT_IDCasdoor client IDNone
CASDOOR_CLIENT_SECRETCasdoor client secretNone
CASDOOR_ORGCasdoor organization name"newsfeed"
CASDOOR_APP_NAMECasdoor application name"newsfeed"
CASDOOR_CERT_PUBLIC_KEYCasdoor public key for JWT verificationNone

Example Configuration #

Here’s an example of a complete backend environment configuration file:

# Backend and worker configuration
REDIS_URL=redis://redis:6379/0
BACKEND_DEBUG="false"
TIMEZONE=America/New_York

# Worker Fetch Configuration
WORKER_FRESHRSS_FETCH_LIMIT=100
WORKER_CONCURRENT_FRESHRSS_FETCH_TASKS=1
WORKER_FRESHRSS_FETCH_DAYS=3
WORKER_FRESHRSS_PURGE_NUM_DAYS_TO_KEEP=7

# Worker Task Scheduling
WORKER_PROCESS_ARTICLES_INTERVAL=15
WORKER_PURGE_OLD_ARTICLES_INTERVAL=1440
WORKER_ENRICH_ARTICLES_INTERVAL=60

# Worker Performance Settings
WORKER_TASK_TIME_LIMIT=300
WORKER_SOFT_TIME_LIMIT=240
WORKER_MAX_TASKS_PER_CHILD=100
WORKER_MAX_MEMORY_PER_CHILD=200000
WORKER_PREFETCH_MULTIPLIER=1

# FreshRSS and FreshRSS API Proxy Setup
FRESHRSS_GREADER_API_URL=https://freshrss.example.com/api/greader.php
FRESHRSS_GREADER_API_USER=newsfeed
FRESHRSS_GREADER_API_PASSWORD=your_password_here

FRESHRSS_PYTHON_API_HOST=https://freshrss.example.com
FRESHRSS_PYTHON_API_USERNAME=newsfeed
FRESHRSS_PYTHON_API_PASSWORD=your_password_here
FRESHRSS_PYTHON_API_VERIFY_SSL=true

# Ollama Configuration
OLLAMA_URL=http://ollama:11434
OLLAMA_MODEL=LLAMA3.2:3B

# Database configuration
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secure_password_here
POSTGRES_DB=newsfeed
POSTGRES_HOST=db

# Casdoor Configuration
CASDOOR_ENDPOINT=http://casdoor:8000
CASDOOR_CLIENT_ID=your_client_id_here
CASDOOR_CLIENT_SECRET=your_client_secret_here
CASDOOR_ORG=newsfeed
CASDOOR_APP_NAME=newsfeed
CASDOOR_CERT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
...
-----END PUBLIC KEY-----"

Environment Variable Precedence #

Environment variables can be set in multiple ways, with the following precedence (highest to lowest):

  1. Docker Compose environment variables
  2. Environment file (env/backend)
  3. Default values in the code

Sensitive Information #

For production deployments, sensitive information such as passwords and API keys should be managed securely:

  1. Use environment variables instead of hardcoding values
  2. Consider using Docker secrets or a secure vault service
  3. Rotate credentials regularly
  4. Use different credentials for development and production environments

Debugging #

When troubleshooting issues with the backend or worker services, the following environment variables can be helpful:

  • Set BACKEND_DEBUG="true" to enable detailed logging
  • Adjust worker task limits (WORKER_TASK_TIME_LIMIT, WORKER_SOFT_TIME_LIMIT) if tasks are timing out
  • Modify WORKER_FRESHRSS_FETCH_LIMIT if you’re experiencing performance issues during article fetching