thiagoeolima / nginx-rtmps

Docker image with Nginx using the nginx-rtmp-module module for streaming and Stunnel to add TLS encryption functionality.
35 stars 21 forks source link
docker live livestream multimedia nginx nginx-rtmp obs-studio rtmp rtmps server stunnel twitch vlc

nginx-rtmps

Docker image with Nginx using the nginx-rtmp-module module for streaming and Stunnel to add TLS encryption functionality.

Description

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/thiagoeolima/nginx-rtmps

Docker Hub image: https://hub.docker.com/r/thiagoeolima/nginx-rtmps/

Details

How to use

docker run -it -p 1935:1935 --name nginx-rtmps thiagoeolima/nginx-rtmps
docker run -it -p 1935:1935 -e FACEBOOK_KEY="<key>" -e YOUTUBE_KEY=<key> thiagoeolima/nginx-rtmps
docker run -it -p 1935:1935 -e CLOUDFLARE_KEY="<key>" thiagoeolima/nginx-rtmps
docker run -it -p 1935:1935 -e TWITCH_URL="rtmp://<url>" -e TWITCH_KEY="<key>" thiagoeolima/nginx-rtmps
docker run -it -p 1935:1935 -e KICK_KEY="<key>" thiagoeolima/nginx-rtmps
rtmp://localhost:1935/live
docker run -it -p 1935:1935 -e INSTAGRAM_KEY=<key> thiagoeolima/nginx-rtmps
rtmp://localhost:1935/instagram

How to test with OBS Studio

Debugging

If something is not working you can check the logs of the container with:

docker logs nginx-rtmps

Extending

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 thiagoeolima/nginx-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;

        #-YouTube
        #push rtmp://a.rtmp.youtube.com/live2/<key>;
        #-Facebook;
        #push rtmp://127.0.0.1:19350/rtmp/<key>;
        #-Instagram;
        #push rtmp://127.0.0.1:19351/rtmp/<key>;
        #-Cloudflare
        #push rtmp://127.0.0.1:19352/live/<key>;
        #-Kick
        #push rtmp://127.0.0.1:19353/kick/<key>;
        }

        application instagram {
            live on;
            record off;

            #-Instagram;
            #push rtmp://127.0.0.1:19351/rtmp/<key>;
        }

    }

}