Skip to main content

Configuration Reference

All proxy settings are configured via environment variables — in a .env file, Docker Compose environment: block, or directly in the shell.

Server

VariableDefaultDescription
HOST0.0.0.0IP address the server binds to
PORT8085Port the server listens on
ROOT_PATH(empty)URL prefix for all routes (e.g. /m3u-proxy). Leave empty if serving at root
LOG_LEVELerrorLogging verbosity: error, warning, info, debug
APP_DEBUGfalseEnable debug mode
RELOADfalseEnable auto-reload on code changes (development only)
DOCS_URL/docsURL for interactive API docs (Swagger UI)
REDOC_URL/redocURL for ReDoc API docs
OPENAPI_URL/openapi.jsonURL for OpenAPI schema
TEMP_DIR/tmp/m3u-proxy-streamsBase directory for temporary stream files
LOG_FILEm3u-proxy.logLog file name

Authentication

VariableDefaultDescription
API_TOKEN(unset)When set, all management endpoints require this token. Leave unset to disable auth. See Authentication

Timeouts & Cleanup

VariableDefaultDescription
CLIENT_TIMEOUT10Seconds of client inactivity before the connection is considered dead
STREAM_TIMEOUT15Seconds allowed for stream operations
SHARED_STREAM_TIMEOUT30Seconds for shared (pooled) stream operations
CLEANUP_INTERVAL30Seconds between cleanup cycles for inactive streams and clients
SHARED_STREAM_GRACE3Grace period (seconds) before a shared FFmpeg process is cleaned up after all clients leave

Connection Idle Monitoring

VariableDefaultDescription
ENABLE_CONNECTION_IDLE_MONITORINGtrueMonitor connections for unusual inactivity
CONNECTION_IDLE_ALERT_THRESHOLD600Seconds before a warning log is emitted for an idle connection
CONNECTION_IDLE_ERROR_THRESHOLD1800Seconds before an error log is emitted for an idle connection

Stream Defaults

These values apply when a stream is created without explicit overrides.

VariableDefaultDescription
DEFAULT_USER_AGENTMozilla/5.0 …User-Agent header sent to upstream providers
DEFAULT_CONNECTION_TIMEOUT10.0Timeout (seconds) for establishing upstream connections
DEFAULT_READ_TIMEOUT30.0Timeout (seconds) for reading data from upstream
DEFAULT_MAX_RETRIES3Maximum connection retries
DEFAULT_BACKOFF_FACTOR1.5Exponential backoff multiplier between retries
DEFAULT_HEALTH_CHECK_INTERVAL300.0Seconds between health checks on active streams
VOD_READ_TIMEOUT3600.0Read timeout for VOD streams (1 hour, to allow pause/resume)
VOD_WRITE_TIMEOUT3600.0Write timeout for VOD streams
LIVE_TV_WRITE_TIMEOUT1800.0Write timeout for live TV streams (30 minutes)

Stream Retry

Controls automatic retry behaviour when a stream encounters a connection error. See Retry Configuration for full details.

VariableDefaultDescription
STREAM_RETRY_ATTEMPTS3Number of retry attempts before failing over to the next URL
STREAM_RETRY_DELAY1.0Seconds to wait between retry attempts
STREAM_TOTAL_TIMEOUT30.0Maximum total time (seconds) across all retries. Set to 0 to disable
STREAM_RETRY_EXPONENTIAL_BACKOFFfalseMultiply STREAM_RETRY_DELAY by 1.5 on each retry
LIVE_CHUNK_TIMEOUT_SECONDS15.0Seconds without receiving data before a chunk timeout is triggered

HLS

VariableDefaultDescription
HLS_GC_ENABLEDtrueEnable garbage collection for stale HLS segments
HLS_GC_INTERVAL600Seconds between HLS GC runs
HLS_GC_AGE_THRESHOLD3600Seconds before an unused HLS segment is eligible for removal
HLS_TEMP_DIR(auto)Base directory for HLS output files
HLS_WAIT_TIME10Seconds to wait for an initial HLS playlist to become available

Stream Sharing (Transcoded Streams)

VariableDefaultDescription
STREAM_SHARING_STRATEGYurl_profileHow shared streams are keyed: url_profile (URL + profile), url_only, or disabled

Broadcast

VariableDefaultDescription
HLS_BROADCAST_DIR/tmp/m3u-proxy-broadcastsDirectory for HLS broadcast output
BROADCAST_CALLBACK_TIMEOUT3Seconds before a broadcast callback times out
BROADCAST_MAX_START_RETRIES3Maximum attempts to start a broadcast process
BROADCAST_START_RETRY_WINDOW300.0Time window (seconds) in which retries are counted
BROADCAST_START_RETRY_COOLDOWN15.0Cooldown (seconds) between retry attempts
BROADCAST_START_FAILURE_GRACE3.0Grace period (seconds) before a failed broadcast is cleaned up

Strict Live TS Mode

Improves stability for live MPEG-TS streams with PVR clients like Kodi. See Strict Live TS.

VariableDefaultDescription
STRICT_LIVE_TSfalseEnable globally for all live TS streams
STRICT_LIVE_TS_PREBUFFER_SIZE262144Pre-buffer size in bytes (default 256 KB)
STRICT_LIVE_TS_CIRCUIT_BREAKER_TIMEOUT2Seconds without data before circuit breaker triggers
STRICT_LIVE_TS_CIRCUIT_BREAKER_COOLDOWN60Seconds to avoid a failed upstream after circuit breaker fires
STRICT_LIVE_TS_PREBUFFER_TIMEOUT10Maximum seconds to wait for pre-buffer to complete

Bitrate Monitoring

Automatically triggers failover when the stream bitrate drops below a threshold.

VariableDefaultDescription
ENABLE_BITRATE_MONITORINGfalseEnable bitrate monitoring
MIN_BITRATE_THRESHOLD62500Minimum acceptable bitrate in bytes/s (default ≈ 500 Kbps)
BITRATE_CHECK_INTERVAL5.0Seconds between bitrate checks
BITRATE_FAILOVER_THRESHOLD3Consecutive low-bitrate readings before failover is triggered
BITRATE_MONITORING_GRACE_PERIOD10.0Seconds after stream start before monitoring begins

Sticky Sessions

See Sticky Sessions.

VariableDefaultDescription
USE_STICKY_SESSIONfalseLock clients to a specific backend after a redirect

Redis (Pooling & Multi-Worker)

Required when using stream pooling or running multiple proxy workers. See Redis Pooling.

VariableDefaultDescription
REDIS_ENABLEDfalseEnable Redis integration
REDIS_HOSTlocalhostRedis server hostname
REDIS_SERVER_PORT6379Redis server port
REDIS_DB0Redis database number
REDIS_PASSWORD(unset)Redis password (if auth is enabled)
ENABLE_TRANSCODING_POOLINGtrueShare transcoding processes across clients
MAX_CLIENTS_PER_SHARED_STREAM10Maximum clients per shared stream
CHANGE_BUFFER_CHUNKS100Buffer size for stream change coordination
WORKER_ID(auto)Unique identifier for this worker instance
HEARTBEAT_INTERVAL30Seconds between worker heartbeat updates

Example Configurations

Minimal (no auth, local testing)

HOST=0.0.0.0
PORT=8085
LOG_LEVEL=info

Production (with auth and Redis)

HOST=0.0.0.0
PORT=8085
LOG_LEVEL=error
API_TOKEN=your-secure-token-here

REDIS_ENABLED=true
REDIS_HOST=redis
REDIS_SERVER_PORT=6379
REDIS_DB=6

STREAM_RETRY_ATTEMPTS=3
STREAM_RETRY_DELAY=1.0
STREAM_TOTAL_TIMEOUT=30.0

CLEANUP_INTERVAL=60

PVR / Kodi optimised

STRICT_LIVE_TS=true
STRICT_LIVE_TS_PREBUFFER_SIZE=262144
STRICT_LIVE_TS_CIRCUIT_BREAKER_TIMEOUT=2
STRICT_LIVE_TS_CIRCUIT_BREAKER_COOLDOWN=60

STREAM_RETRY_ATTEMPTS=3
STREAM_RETRY_DELAY=1.0

High concurrency

REDIS_ENABLED=true
MAX_CLIENTS_PER_SHARED_STREAM=20
CLEANUP_INTERVAL=30
ENABLE_BITRATE_MONITORING=true
MIN_BITRATE_THRESHOLD=62500
BITRATE_CHECK_INTERVAL=5.0
BITRATE_FAILOVER_THRESHOLD=3