Configuration Overview
This guide explains how to configure docker-rtmp-multistream, covering environment variables, Docker volumes, and the overall configuration system.
Configuration Layers
The system uses a layered configuration approach:
- Dockerfile - Default values for all settings
- env/relay.env - User customizations (this is what you edit)
- docker-compose.yml - Docker setup and volume mappings
- Runtime - Configuration files generated at container startup
Environment Variables
Configuration File
All user configuration happens in env/relay.env
. This file contains environment variables that control service enablement and behavior.
Security
Never commit env/relay.env
to version control if it contains stream keys or secrets. The included .gitignore
prevents this by default.
File Structure
The env/relay.env
file is organized by service:
# System Configuration
PUBLISH_IP_RANGE=192.168.0.0/16
# Twitch Service
TWITCH_KEY=
TWITCH_HEIGHT=720
TWITCH_FPS=60
# ... more Twitch settings
# YouTube Service
YOUTUBE_KEY=
# Archive Service
ARCHIVE_PATH=
ARCHIVE_SUFFIX=flv
Required vs Optional Variables
Required for service enablement:
- TWITCH_KEY
- Enables Twitch streaming
- YOUTUBE_KEY
- Enables YouTube streaming
- ARCHIVE_PATH
- Enables local archiving
If these are empty or unset, the corresponding service is disabled.
Optional variables: - All other variables have sensible defaults - Only override when you need different behavior
Service Enablement
Services are automatically enabled or disabled based on configuration:
Example: Enabling Twitch Only
env/relay.env:
TWITCH_KEY=live_123456789_abcdefghijklmnopqrstuvwxyz
# YOUTUBE_KEY= (commented out or empty)
# ARCHIVE_PATH= (commented out or empty)
Result: Only Twitch streams, YouTube and Archive are disabled.
Example: Enabling All Services
env/relay.env:
TWITCH_KEY=live_123456789_abcdefghijklmnopqrstuvwxyz
YOUTUBE_KEY=abcd-efgh-ijkl-mnop-qrst
ARCHIVE_PATH=/archive
docker-compose.yml (add volume for archive):
Result: All services active.
Docker Compose Configuration
Basic Setup
The minimal docker-compose.yml
:
Adding Persistent Archive
To save archived streams permanently:
services:
relay:
build:
context: .
ports:
- "1935:1935"
env_file:
- ./env/relay.env
volumes:
- ./stream_archive:/archive # Host directory : Container path
Then set permissions:
And configure in env/relay.env
:
Port Mapping
The relay listens on port 1935 (RTMP standard port).
Default mapping:
Custom host port (if 1935 is already in use):
Then stream to: rtmp://<relay-ip>:1936/relay/<key>
Security Configuration
IP-Based Access Control
The PUBLISH_IP_RANGE
variable controls which IP addresses can publish streams to the relay.
Default (entire local network):
Single IP (only one specific machine):
Multiple networks (combine in nginx config):
CIDR Notation
/32
= single IP address/24
= 256 addresses (192.168.1.0 - 192.168.1.255)/16
= 65,536 addresses (192.168.0.0 - 192.168.255.255)
Stream Key Security
Your streaming software uses a stream key that's independent of service keys:
OBS Stream Settings:
This key is not your Twitch/YouTube key - it's just an identifier for your stream on the relay.
Configuration Flow
Understanding how configuration is processed:
1. Container starts
↓
2. Docker loads env/relay.env
↓
3. Pre-init scripts execute in order:
- Check which services should be enabled
- Replace placeholder variables in config files
- Enable services by uncommenting includes
↓
4. nginx starts with active configuration
↓
5. Ready to receive streams
Pre-init Script Order
Scripts in build/scripts/pre-init.d/
run in alphanumeric order:
89_configure_app.sh
- Main relay application90_configure_twitch.sh
- Twitch service90_configure_youtube.sh
- YouTube service90_configure_archive.sh
- Archive service
Template Variables
Configuration files use placeholders like {TWITCH_KEY}
that are replaced at runtime:
Before (apps/twitch.conf
):
After processing:
Common Configuration Patterns
Pattern 1: Stream to Twitch and YouTube
# env/relay.env
TWITCH_KEY=live_123456789_abcdefghijklmnopqrstuvwxyz
TWITCH_HEIGHT=720
TWITCH_FPS=60
YOUTUBE_KEY=abcd-efgh-ijkl-mnop-qrst
Pattern 2: Stream and Archive
# env/relay.env
YOUTUBE_KEY=abcd-efgh-ijkl-mnop-qrst
ARCHIVE_PATH=/archive
ARCHIVE_SUFFIX=mp4 # or flv (default)
Pattern 3: Test/Development (Archive Only)
Useful for testing without actually streaming to services.
Applying Configuration Changes
After editing env/relay.env
or docker-compose.yml
:
Method 1: Restart (Recommended)
Method 2: Rebuild (If Dockerfile changed)
Method 3: Quick Restart (Existing build)
When to Rebuild
Rebuild is only needed if you modified:
- Dockerfile
- Config files in build/conf/
- Scripts in build/scripts/
Changing env/relay.env
only requires restart.
Configuration Reference
For complete details on all environment variables, see:
Validation
Check Active Services
After starting, verify which services are enabled:
Expected output:
Test Configuration Syntax
Should show: nginx: configuration file /etc/nginx/nginx.conf test is successful
View Active Configuration
Look for uncommented include
directives for your enabled services.
See Also
- Architecture - How configuration is processed
- Quick Start Guide - Step-by-step setup
- Troubleshooting - Configuration issues
- Environment Variables Reference - Complete variable listing