Sign inSign up

kitce/nginx-rtmp

By kitce

•Updated about 9 years ago

Official nginx docker image + nginx-rtmp-module

Image
0

477

kitce/nginx-rtmp repository overview

Everything is same as the official nginx docker image (mainline-alpine) (https://hub.docker.com/_/nginx/⁠) Except it contains nginx-rtmp-module (https://github.com/arut/nginx-rtmp-module⁠)

⁠Expose

80, 443, 1935

⁠RTMP configuration

Put the configuration files to the container /etc/nginx/conf.d/rtmp/ with the extension .conf

⁠Example

/etc/nginx/conf.d/rtmp/live.conf

server {
    listen 1935;
    ping 30s;
    ping_timeout 10s;
    application live {
        live on;
        wait_key on;
        play_restart on;
    }
}

⁠Usage

⁠Command

docker run -d -p 8080:80 -p 8443:443 -p 1935:1935 kitce/nginx-rtmp

⁠On host

Stream URL : rtmp://localhost:1935/live/ Stream Key : <your-stream-name> RTMP video stream will be available on rtmp://localhost:1935/live/<your-stream-name>

⁠HLS

If you need HLS, you need to modify the above RTMP configuration and configure http for nginx as well. The HLS fragments and playlist will be available when you start publishing on RTMP.

⁠Example

In /etc/nginx/conf.d/rtmp/live.conf, add few lines to enable HLS

server {
    ...
    application live {
        ...
        hls on;
        hls_path /tmp/hls;
        hls_fragment 5s;
        hls_playlist_length 30s;
    }
}

In /etc/nginx/conf.d/hls.conf, make /tmp as the root of /hls. Therefore, paths to /hls will be served with /tmp/hls.

server {
    listen 80;
    location /hls {
        root /tmp;
        add_header Access-Control-Allow-Origin * always;
        add_header Cache-Control no-cache;
        types {
            application/vnd.apple.mpegurl m3u8;
            video/mp2t ts;
        }
    }
}

⁠On host

The stream will be available with the url http://localhost:8080/hls/<your-stream-name>.m3u8

Tag summary

Content type

Image

Digest

Size

10.3 MB

Last updated

about 9 years ago

docker pull kitce/nginx-rtmp