From ab1ab1eb07bdef39a8f0ca184edd31199c8b83b0 Mon Sep 17 00:00:00 2001 From: deflax Date: Mon, 11 Oct 2021 00:31:32 +0000 Subject: [PATCH] build nginx with http-flv module --- config/frontend/config.yml.dist | 25 ------------- docker-compose.yml | 2 ++ rtmp/Dockerfile | 64 ++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 26 deletions(-) delete mode 100644 config/frontend/config.yml.dist diff --git a/config/frontend/config.yml.dist b/config/frontend/config.yml.dist deleted file mode 100644 index 23b0fd9..0000000 --- a/config/frontend/config.yml.dist +++ /dev/null @@ -1,25 +0,0 @@ -# This is the title and Subtitle displayed on the Head of the Page -pagetitle: vod-rtmp -subtitle: v1 - -# the footer -footer: "© 2021 by the zom.bi Team" - -# the ip or hostname used to generate rtmp URLs -rtmp_base: stream.example.com - -# this is the base url used to generate internal links -base_url: 127.0.0.1:5001 - -# the url to the nginx servers status page. -# this is used for discovering the running streams -# if you are running the docker-compose setup you don't need to change that. -stat_url : http://nginx-rtmp:18080/stat - -# web protocol - used for generating hls and internal links. -# change this to https if you are using https for example via traefik in front of this setup -web_proto: http - -# if you want to add another template you can place it in the "templates" folder -# leave it at "default" to use the included default template -template_folder: default diff --git a/docker-compose.yml b/docker-compose.yml index 7277f25..74e7222 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,8 @@ services: rtmp: build: ./rtmp hostname: rtmp + ports: + - "18080:18080" volumes: - "./data/rtmp/hls:/tmp/hls" depends_on: diff --git a/rtmp/Dockerfile b/rtmp/Dockerfile index 2a0c521..954620b 100644 --- a/rtmp/Dockerfile +++ b/rtmp/Dockerfile @@ -1,11 +1,73 @@ -FROM tiangolo/nginx-rtmp +FROM buildpack-deps:stretch +# Versions of modules to use +ENV NGINX_VERSION nginx-1.18.0 +ENV NGINX_RTMP_MODULE_VERSION 1.2.1 +ENV NGINX_HTTP_FLV_MODULE_VERSION 1.2.9 + +# Install dependencies +RUN apt-get update && \ + apt-get install -y ca-certificates openssl libssl-dev && \ + rm -rf /var/lib/apt/lists/* + +# Download and decompress Nginx +RUN mkdir -p /tmp/build/nginx && \ + cd /tmp/build/nginx && \ + wget -O ${NGINX_VERSION}.tar.gz https://nginx.org/download/${NGINX_VERSION}.tar.gz && \ + tar -zxf ${NGINX_VERSION}.tar.gz + +# Download and decompress RTMP module +RUN mkdir -p /tmp/build/nginx-rtmp-module && \ + cd /tmp/build/nginx-rtmp-module && \ + wget -O nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION}.tar.gz https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_MODULE_VERSION}.tar.gz && \ + tar -zxf nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION}.tar.gz && \ + cd nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION} + +# Download and decompress HTTP FLV module +RUN mkdir -p /tmp/build/nginx-http-flv-module && \ + cd /tmp/build/nginx-http-flv-module && \ + wget -O nginx-http-flv-module-${NGINX_HTTP_FLV_MODULE_VERSION}.tar.gz https://github.com/winshining/nginx-http-flv-module/archive/v${NGINX_HTTP_FLV_MODULE_VERSION}.tar.gz && \ + tar -zxf nginx-http-flv-module-${NGINX_HTTP_FLV_MODULE_VERSION}.tar.gz && \ + cd nginx-http-flv-module-${NGINX_HTTP_FLV_MODULE_VERSION} + +# Build and install Nginx +# The default puts everything under /usr/local/nginx, so it's needed to change +# it explicitly. Not just for order but to have it in the PATH +RUN cd /tmp/build/nginx/${NGINX_VERSION} && \ + ./configure \ + --sbin-path=/usr/local/sbin/nginx \ + --conf-path=/etc/nginx/nginx.conf \ + --error-log-path=/var/log/nginx/error.log \ + --pid-path=/var/run/nginx/nginx.pid \ + --lock-path=/var/lock/nginx/nginx.lock \ + --http-log-path=/var/log/nginx/access.log \ + --http-client-body-temp-path=/tmp/nginx-client-body \ + --with-http_ssl_module \ + --with-threads \ + --with-ipv6 \ + --add-module=/tmp/build/nginx-http-flv-module/nginx-http-flv-module-${NGINX_HTTP_FLV_MODULE_VERSION} && \ + #--add-module=/tmp/build/nginx-rtmp-module/nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION} && \ + make -j $(getconf _NPROCESSORS_ONLN) && \ + make install && \ + mkdir /var/lock/nginx && \ + rm -rf /tmp/build + +# Forward logs to Docker +RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ + ln -sf /dev/stderr /var/log/nginx/error.log + +# Set up config file COPY nginx.conf /etc/nginx/nginx.conf COPY mime.types /etc/nginx/mime.types +# Copy fallback data COPY index.html /www/ COPY network.m3u8 /www/ COPY network0.ts /www/ COPY network1.ts /www/ +EXPOSE 1935 EXPOSE 8080 +EXPOSE 18080 +CMD ["nginx", "-g", "daemon off;"] +