diff --git a/Dockerfile b/Dockerfile index 0848639..f7985e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ LABEL maintainer="Sebastian Ramirez " # Versions of Nginx and nginx-rtmp-module to use ENV NGINX_VERSION nginx-1.18.0 -ENV NGINX_RTMP_MODULE_VERSION 1.2.1 +ENV NGINX_RTMP_MODULE_VERSION 1.2.2 # Install dependencies RUN apt-get update && \ @@ -51,6 +51,10 @@ RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ # Set up config file COPY nginx.conf /etc/nginx/nginx.conf +RUN mkdir -p /tmp/hls/live +# RTMP EXPOSE 1935 +# HLS +EXPOSE 8080 CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf index 723e721..6c45dea 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,14 +1,54 @@ worker_processes auto; rtmp_auto_push on; events {} + +# See https://github.com/arut/nginx-rtmp-module for details. rtmp { server { listen 1935; - listen [::]:1935 ipv6only=on; + listen [::]:1935 ipv6only=on; application live { live on; record off; + + # record first 1K of stream + #record all; + #record_path /tmp/av; + #record_max_size 1K; + + # append current timestamp to each flv + #record_unique on; + + # publish only from localhost + #allow publish 127.0.0.1; + #deny publish all; + + # this is the default, allow everyone to play + #allow play all; + + # see http section related + hls on; + hls_path /tmp/hls/live; + hls_type live; + hls_fragment 5s; + hls_playlist_length 15s; + } + } +} + +http { + server { + listen 8080; + + location /live { + # Serve HLS fragments + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + root /tmp/hls; + add_header Cache-Control no-cache; } } }