This Docker image can be used to create a video streaming server ( With support both of Live and VOD ) that supports RTMP input and HLS out of the box. It also allows adaptive streaming and custom transcoding of video streams. All modules are built from source on Debian and Alpine Linux base images.
- The backend is Nginx with nginx-rtmp-module and nginx-vod-module.
- FFmpeg for transcoding and adaptive streaming. (Just for Live streaming)
- Default settings:
- RTMP is ON
- HLS Live is ON (adaptive, multi variants by call ffmpeg on config)
- HLS VOD is ON
Current Image is built using:
- Nginx 1.18.0 (compiled from source)
- Nginx-rtmp-module 1.2.1 (compiled from source)
- Nginx-vod-module 1.27 (compiled from source)
- FFmpeg 4.3.1 (compiled from source)
This image was inspired by similar docker images from TareqAlqutami and dojocasts and nytimes.
Install docker on server, after that just run : docker pull voltan/nginx-stream
After install this image, Set domain or sub domain to server IP on your domain or dns control panel, and call all urls by domain instead of server IP, Push to this domain and watch output on this domain too
- You can by ssl certificate for your domain, upload certificate on server and put certificate path in docker run command.
- If you want use LetsEncrypt ( certbot ), setup certbot on your server and create certificate for your domain and put certificate path in docker run command.
- Install LetsEncrypt ( certbot ) on server
yum -y install yum-utils yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional yum install certbot
- Make well-known path on
/var/www/.well-known
, by this commandmkdir /var/www/.well-known
- Run docker image by
nginx_simple.conf
on port 80 and 443 like this example just for setup SSL by default nginx configdocker run -p 1935:1935 -p 80:80 -p 443:443 -v $PWD/conf/nginx_simple.conf:/etc/nginx/nginx.conf -v /var/www:/var/www nginx-stream
- Run cerboot like this ( replace
www.example.com
to your domain name )certbot certonly --webroot -w /var/www/ -d www.example.com
- After setup SSL certificate, stop container and go to next steps
- You should run this image just by customize
[nginx_domain.conf]()
ornginx_domain_ffmpeg.conf
(for multi bitrate support by ffmpeg)- Get nginx_domain.conf for run service normally
- Get nginx_domain_ffmpeg.conf for run multi bitrate support by ffmpeg
- Create
videos
folder on your server VOD server and put your videos on it - Edit
nginx_domain.conf
ornginx_domain_ffmpeg.conf
and put replacewww.example.com
to your domain name and put it on your server - Edit
nginx_domain.conf
ornginx_domain_ffmpeg.conf
and put SSL certificate information on it ( by default, LetsEncrypt information added ) - Run image by command like this :
docker run -p 1935:1935 -p 80:80 -p 443:443 -v $PWD/conf/nginx_domain.conf:/etc/nginx/nginx.conf -v $PWD/videos:/opt/static/videos -v /var/www:/var/www -v /etc/letsencrypt:/etc/letsencrypt voltan/nginx-stream
- For run image on background, just add
-d
after docker run on previous command
Stream RTMP to server
rtmp://www.example.com:1935/live/<stream_key>
View Live stream
https://www.example.com/hls/<stream-key>.m3u8
View VOD stream
https://www.example.com/vod/<file-name>.mp4/master.m3u8
Statistic
https://www.example.com/stats
- Install docker on server
- Clone this git repo by :
git clone https://github.com/voltan/nginx-stream.git
- Build image by :
docker build -t nginx-stream -f Dockerfile .
- Continue by setup domain, ssl and run service
Released under MIT license.