Docker image with Nginx using the nginx-rtmp-module module for streaming and Stunnel to add TLS encryption functionality.
This Docker image can be used to create an RTMP server for multimedia / video streaming using Nginx, nginx-rtmp-module and Stunnel, built from the current latest sources (Nginx 1.18.0 , nginx-rtmp-module 1.2.1 and Stunnel 4).
This was inspired by other similar previous images from tiangolo, dvdgiessen, jasonrivers, aevumdecessus and by an OBS Studio post.
The main purpose (and test case) to build it was to allow streaming from OBS Studio to different clients at the same time.
GitHub repo: https://github.com/mach7enterprises/rtmps
Docker Hub image: https://hub.docker.com/r/mach7enterprises/rtmps/
- For the simplest case, just run a container with this image:
docker run -it -p 1935:1935 --name nginx-rtmps mach7enterprises/rtmps
- Facebook and Youtube:
docker run -it -p 1935:1935 -e FACEBOOK_KEY=<key> -e YOUTUBE_KEY=<key> mach7enterprises/rtmps
- OBS
rtmp://localhost:1935/live
- Instagram:
docker run -it -p 1935:1935 -e INSTAGRAM_KEY=<key> mach7enterprises/rtmps
- OBS
rtmp://localhost:1935/instagram
-
Run a container with the command above
-
Open OBS Studio
-
Click the "Settings" button
-
Go to the "Stream" section
-
In "Stream Type" select "Custom Streaming Server"
-
In the "URL" enter the
rtmp://<ip_of_host>/live
replacing<ip_of_host>
with the IP of the host in which the container is running. For example:rtmp://192.168.0.30/live
-
In the "Stream key" use a "key" that will be used later in the client URL to display that specific stream. For example:
test
-
Click the "OK" button
-
In the section "Sources" click de "Add" button (
+
) and select a source (for example "Screen Capture") and configure it as you need -
Click the "Start Streaming" button
If something is not working you can check the logs of the container with:
docker logs nginx-rtmps
If you need to modify the configurations you can create a file nginx.conf
and replace the one in this image using a Dockerfile
that is based on the image, for example:
FROM mach7enterprises/rtmps
COPY nginx.conf /etc/nginx/nginx.conf
The current nginx.conf
contains:
worker_processes auto;
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
events {}
rtmp {
server {
listen 1935;
listen [::]:1935 ipv6only=on;
chunk_size 4096;
application live {
live on;
record off;
#push rtmp://a.rtmp.youtube.com/live2/<key>;
#push rtmp://127.0.0.1:19350/rtmp/<key>;
}
application instagram {
live on;
record off;
#push rtmp://127.0.0.1:19351/rtmp/<key>;
}
}
}