puike-site
This commit is contained in:
commit
d1e8e426de
317
Dockerfile
Normal file
317
Dockerfile
Normal file
@ -0,0 +1,317 @@
|
||||
ARG RESTY_IMAGE_BASE="alpine"
|
||||
ARG RESTY_IMAGE_TAG="3.13"
|
||||
ARG FFMPEG_VERSION=4.4
|
||||
|
||||
##############################
|
||||
# Build the OpenResty-build image.
|
||||
# mostly from https://github.com/openresty/docker-openresty/blob/master/alpine/Dockerfile
|
||||
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} as build-openresty
|
||||
|
||||
ARG RESTY_IMAGE_BASE
|
||||
ARG RESTY_IMAGE_TAG
|
||||
ARG RESTY_VERSION="1.19.3.1"
|
||||
ARG RESTY_OPENSSL_VERSION="1.1.1k"
|
||||
ARG RESTY_OPENSSL_PATCH_VERSION="1.1.1f"
|
||||
ARG RESTY_OPENSSL_URL_BASE="https://www.openssl.org/source"
|
||||
ARG RESTY_PCRE_VERSION="8.44"
|
||||
ARG RESTY_J="4"
|
||||
ARG RESTY_CONFIG_OPTIONS="\
|
||||
--with-compat \
|
||||
--with-file-aio \
|
||||
--with-http_addition_module \
|
||||
--with-http_auth_request_module \
|
||||
--with-http_dav_module \
|
||||
--with-http_flv_module \
|
||||
--with-http_geoip_module=dynamic \
|
||||
--with-http_gunzip_module \
|
||||
--with-http_gzip_static_module \
|
||||
--with-http_image_filter_module=dynamic \
|
||||
--with-http_mp4_module \
|
||||
--with-http_random_index_module \
|
||||
--with-http_realip_module \
|
||||
--with-http_secure_link_module \
|
||||
--with-http_slice_module \
|
||||
--with-http_ssl_module \
|
||||
--with-http_stub_status_module \
|
||||
--with-http_sub_module \
|
||||
--with-http_v2_module \
|
||||
--with-http_xslt_module=dynamic \
|
||||
--with-ipv6 \
|
||||
--with-mail \
|
||||
--with-mail_ssl_module \
|
||||
--with-md5-asm \
|
||||
--with-pcre-jit \
|
||||
--with-sha1-asm \
|
||||
--with-stream \
|
||||
--with-stream_ssl_module \
|
||||
--with-threads \
|
||||
"
|
||||
ARG RESTY_CONFIG_OPTIONS_MORE=""
|
||||
ARG RESTY_LUAJIT_OPTIONS="--with-luajit-xcflags='-DLUAJIT_NUMMODE=2 -DLUAJIT_ENABLE_LUA52COMPAT'"
|
||||
|
||||
ARG RESTY_ADD_PACKAGE_BUILDDEPS=""
|
||||
ARG RESTY_ADD_PACKAGE_RUNDEPS=""
|
||||
ARG RESTY_EVAL_PRE_CONFIGURE=""
|
||||
ARG RESTY_EVAL_POST_MAKE=""
|
||||
|
||||
ARG NGINX_RTMP_VERSION=1.2.1
|
||||
|
||||
# These are not intended to be user-specified
|
||||
ARG _RESTY_CONFIG_DEPS="--add-module=/tmp/nginx-rtmp-module-${NGINX_RTMP_VERSION} --with-pcre \
|
||||
--with-cc-opt='-DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' \
|
||||
--with-ld-opt='-L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' \
|
||||
"
|
||||
|
||||
|
||||
# Build dependencies.
|
||||
RUN apk add --update \
|
||||
build-base \
|
||||
coreutils \
|
||||
ca-certificates \
|
||||
curl \
|
||||
linux-headers \
|
||||
libc-dev \
|
||||
libgcc \
|
||||
musl-dev \
|
||||
pcre-dev \
|
||||
zlib-dev \
|
||||
perl-dev \
|
||||
gd-dev \
|
||||
geoip-dev \
|
||||
libxslt-dev \
|
||||
gcc \
|
||||
make \
|
||||
pkgconf \
|
||||
pkgconfig
|
||||
|
||||
# get and build openssl source
|
||||
RUN cd /tmp \
|
||||
&& if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \
|
||||
&& cd /tmp \
|
||||
&& curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
||||
&& tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \
|
||||
&& cd openssl-${RESTY_OPENSSL_VERSION} \
|
||||
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.1" ] ; then \
|
||||
echo 'patching OpenSSL 1.1.1 for OpenResty' \
|
||||
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \
|
||||
fi \
|
||||
&& if [ $(echo ${RESTY_OPENSSL_VERSION} | cut -c 1-5) = "1.1.0" ] ; then \
|
||||
echo 'patching OpenSSL 1.1.0 for OpenResty' \
|
||||
&& curl -s https://raw.githubusercontent.com/openresty/openresty/ed328977028c3ec3033bc25873ee360056e247cd/patches/openssl-1.1.0j-parallel_build_fix.patch | patch -p1 \
|
||||
&& curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 ; \
|
||||
fi \
|
||||
&& ./config \
|
||||
no-threads shared zlib -g \
|
||||
enable-ssl3 enable-ssl3-method \
|
||||
--prefix=/usr/local/openresty/openssl \
|
||||
--libdir=lib \
|
||||
-Wl,-rpath,/usr/local/openresty/openssl/lib \
|
||||
&& make -j${RESTY_J} \
|
||||
&& make -j${RESTY_J} install_sw
|
||||
|
||||
# get and build pcre source
|
||||
RUN cd /tmp \
|
||||
&& curl -fSL https://ftp.pcre.org/pub/pcre/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
||||
&& tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz && rm pcre-${RESTY_PCRE_VERSION}.tar.gz \
|
||||
&& cd /tmp/pcre-${RESTY_PCRE_VERSION} \
|
||||
&& ./configure \
|
||||
--prefix=/usr/local/openresty/pcre \
|
||||
--disable-cpp \
|
||||
--enable-jit \
|
||||
--enable-utf \
|
||||
--enable-unicode-properties \
|
||||
&& make -j${RESTY_J} \
|
||||
&& make -j${RESTY_J} install
|
||||
|
||||
# Get nginx-rtmp module.
|
||||
RUN cd /tmp \
|
||||
&& wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_VERSION}.tar.gz \
|
||||
&& tar zxf v${NGINX_RTMP_VERSION}.tar.gz && rm v${NGINX_RTMP_VERSION}.tar.gz
|
||||
|
||||
# get and build openresty source
|
||||
RUN cd /tmp \
|
||||
&& curl -fSL https://openresty.org/download/openresty-${RESTY_VERSION}.tar.gz -o openresty-${RESTY_VERSION}.tar.gz \
|
||||
&& tar xzf openresty-${RESTY_VERSION}.tar.gz && rm openresty-${RESTY_VERSION}.tar.gz \
|
||||
&& cd /tmp/openresty-${RESTY_VERSION} \
|
||||
&& eval ./configure -j${RESTY_J} ${_RESTY_CONFIG_DEPS} ${RESTY_CONFIG_OPTIONS} ${RESTY_CONFIG_OPTIONS_MORE} ${RESTY_LUAJIT_OPTIONS} \
|
||||
&& make -j${RESTY_J} \
|
||||
&& make -j${RESTY_J} install
|
||||
|
||||
|
||||
###############################
|
||||
# Build the FFmpeg-build image.
|
||||
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} as build-ffmpeg
|
||||
ARG FFMPEG_VERSION
|
||||
ARG PREFIX=/usr/local
|
||||
ARG MAKEFLAGS="-j4"
|
||||
|
||||
# FFmpeg build dependencies.
|
||||
RUN apk add --update \
|
||||
build-base \
|
||||
coreutils \
|
||||
freetype-dev \
|
||||
lame-dev \
|
||||
libogg-dev \
|
||||
libass \
|
||||
libass-dev \
|
||||
libvpx-dev \
|
||||
libvorbis-dev \
|
||||
libwebp-dev \
|
||||
libtheora-dev \
|
||||
openssl-dev \
|
||||
opus-dev \
|
||||
pkgconf \
|
||||
pkgconfig \
|
||||
rtmpdump-dev \
|
||||
wget \
|
||||
x264-dev \
|
||||
x265-dev \
|
||||
yasm
|
||||
|
||||
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
|
||||
RUN apk add --update fdk-aac-dev
|
||||
|
||||
# Get FFmpeg source.
|
||||
RUN cd /tmp/ && \
|
||||
wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
|
||||
tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && rm ffmpeg-${FFMPEG_VERSION}.tar.gz
|
||||
|
||||
# Compile ffmpeg.
|
||||
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \
|
||||
./configure \
|
||||
--prefix=${PREFIX} \
|
||||
--enable-version3 \
|
||||
--enable-gpl \
|
||||
--enable-nonfree \
|
||||
--enable-small \
|
||||
--enable-libmp3lame \
|
||||
--enable-libx264 \
|
||||
--enable-libx265 \
|
||||
--enable-libvpx \
|
||||
--enable-libtheora \
|
||||
--enable-libvorbis \
|
||||
--enable-libopus \
|
||||
--enable-libfdk-aac \
|
||||
--enable-libass \
|
||||
--enable-libwebp \
|
||||
--enable-postproc \
|
||||
--enable-avresample \
|
||||
--enable-libfreetype \
|
||||
--enable-openssl \
|
||||
--disable-debug \
|
||||
--disable-doc \
|
||||
--disable-ffplay \
|
||||
--extra-libs="-lpthread -lm" && \
|
||||
make && make install && make distclean
|
||||
|
||||
# Cleanup.
|
||||
RUN rm -rf /var/cache/* /tmp/*
|
||||
|
||||
|
||||
######################################
|
||||
# Create FAT version of openresty-rtmp
|
||||
FROM build-openresty as build-openresty-fat
|
||||
|
||||
ARG RESTY_LUAROCKS_VERSION="3.7.0"
|
||||
|
||||
RUN apk add --no-cache --virtual .build-deps \
|
||||
perl-dev \
|
||||
&& apk add --no-cache \
|
||||
bash \
|
||||
build-base \
|
||||
curl \
|
||||
libintl \
|
||||
linux-headers \
|
||||
make \
|
||||
musl \
|
||||
outils-md5 \
|
||||
perl \
|
||||
unzip \
|
||||
&& cd /tmp \
|
||||
&& curl -fSL https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz -o luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
||||
&& tar xzf luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
||||
&& cd luarocks-${RESTY_LUAROCKS_VERSION} \
|
||||
&& ./configure \
|
||||
--prefix=/usr/local/openresty/luajit \
|
||||
--with-lua=/usr/local/openresty/luajit \
|
||||
--lua-suffix=jit-2.1.0-beta3 \
|
||||
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 \
|
||||
&& make build \
|
||||
&& make install \
|
||||
&& cd /tmp \
|
||||
&& rm -rf luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
|
||||
&& apk add --no-cache --virtual .gettext gettext \
|
||||
&& mv /usr/bin/envsubst /tmp/ \
|
||||
&& apk del .build-deps .gettext \
|
||||
&& mv /tmp/envsubst /usr/local/bin/
|
||||
|
||||
# Add LuaRocks paths
|
||||
# If OpenResty changes, these may need updating:
|
||||
# /usr/local/openresty/bin/resty -e 'print(package.path)'
|
||||
# /usr/local/openresty/bin/resty -e 'print(package.cpath)'
|
||||
ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua"
|
||||
ENV LUA_CPATH="/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so"
|
||||
|
||||
ENV PATH="/usr/local/openresty/bin:/usr/local/openresty/luajit/bin:$PATH"
|
||||
|
||||
ENV LAPIS_VERSION=1.8.3
|
||||
|
||||
RUN apk add openssl-dev
|
||||
RUN opm get spacewander/luafilesystem
|
||||
RUN luarocks install luasec
|
||||
RUN luarocks install busted
|
||||
RUN luarocks install --check-lua-versions markov-text
|
||||
RUN luarocks install lapis ${LAPIS_VERSION}
|
||||
RUN luarocks install moonscript
|
||||
|
||||
|
||||
##########################
|
||||
# Build the release image.
|
||||
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} as openresty-rtmp
|
||||
LABEL MAINTAINER dreamer <dreamer@puikheid.nl>
|
||||
|
||||
# Set default ports.
|
||||
ENV HTTP_PORT 8080
|
||||
ENV RTMP_PORT 1935
|
||||
|
||||
RUN apk add --update \
|
||||
ca-certificates \
|
||||
gettext \
|
||||
libgcc \
|
||||
geoip \
|
||||
gd \
|
||||
libxslt \
|
||||
zlib \
|
||||
lame \
|
||||
libogg \
|
||||
curl \
|
||||
libass \
|
||||
libvpx \
|
||||
libvorbis \
|
||||
libwebp \
|
||||
libtheora \
|
||||
opus \
|
||||
rtmpdump \
|
||||
x264-dev \
|
||||
x265-dev
|
||||
|
||||
|
||||
COPY --from=build-openresty-fat /usr/local/openresty /usr/local/openresty
|
||||
COPY --from=build-ffmpeg /usr/local /usr/local
|
||||
COPY --from=build-ffmpeg /usr/lib/libfdk-aac.so.2 /usr/lib/libfdk-aac.so.2
|
||||
|
||||
# Add NGINX path, config and static files.
|
||||
ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua"
|
||||
ENV LUA_CPATH="/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so"
|
||||
|
||||
ENV PATH="/usr/local/openresty/bin:/usr/local/openresty/luajit/bin:$PATH"
|
||||
|
||||
RUN mkdir -p /opt/data && mkdir /www
|
||||
# ADD static /www/static
|
||||
|
||||
EXPOSE 1935
|
||||
EXPOSE 8080
|
||||
|
||||
WORKDIR /srv/lapis
|
||||
|
||||
CMD lapis server $ENVIRONMENT
|
||||
14
code/app.lua
Normal file
14
code/app.lua
Normal file
@ -0,0 +1,14 @@
|
||||
local lapis = require("lapis")
|
||||
|
||||
local app = lapis.Application()
|
||||
app:enable("etlua")
|
||||
app.layout = require "views.layout"
|
||||
|
||||
local autoload = require("lapis.util").autoload
|
||||
local handlers = autoload("handlers")
|
||||
|
||||
app:get("/", function(self)
|
||||
return handlers.Roothandler(self)
|
||||
end)
|
||||
|
||||
return app
|
||||
8
code/handlers/roothandler.lua
Normal file
8
code/handlers/roothandler.lua
Normal file
@ -0,0 +1,8 @@
|
||||
local autoload = require("lapis.util").autoload
|
||||
|
||||
|
||||
local function Roothandler(self)
|
||||
return { render = "root" }
|
||||
end
|
||||
|
||||
return Roothandler
|
||||
83
code/mime.types
Normal file
83
code/mime.types
Normal file
@ -0,0 +1,83 @@
|
||||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/x-lua lua;
|
||||
application/x-moonscript moon;
|
||||
application/x-javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
application/json json;
|
||||
application/x-bittorrent torrent;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/png png;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
image/svg+xml svg svgz;
|
||||
image/webp webp;
|
||||
|
||||
application/java-archive jar war ear;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream eot;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
||||
108
code/nginx.conf
Normal file
108
code/nginx.conf
Normal file
@ -0,0 +1,108 @@
|
||||
worker_processes ${{NUM_WORKERS}};
|
||||
error_log stderr notice;
|
||||
daemon off;
|
||||
pid logs/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
rtmp {
|
||||
server {
|
||||
listen 1935;
|
||||
chunk_size 4000;
|
||||
|
||||
application stream {
|
||||
live on;
|
||||
|
||||
#relays the incoming video to low quality streams on this server, audio-only version and to a different server
|
||||
exec ffmpeg -i rtmp://localhost:1935/stream/$name
|
||||
-c:a copy -c:v copy -f flv rtmp://localhost/hls/$name_hi;
|
||||
exec ffmpeg -i rtmp://localhost:1935/stream/$name -max_muxing_queue_size 1024
|
||||
-c:a copy -c:v libx264 -b:v 500K -preset superfast -profile:v baseline -f flv rtmp://localhost/hls/$name_low
|
||||
2>/mnt/radio/logs/ffmpeg-$name_low.log;
|
||||
}
|
||||
|
||||
|
||||
application hls {
|
||||
live on;
|
||||
hls on;
|
||||
hls_fragment_naming system;
|
||||
hls_fragment 3;
|
||||
hls_playlist_length 60;
|
||||
hls_path /opt/data/hls;
|
||||
hls_nested on;
|
||||
|
||||
hls_variant _hi BANDWIDTH=640000;
|
||||
hls_variant _low BANDWIDTH=160000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
|
||||
init_by_lua_block {
|
||||
require("socket")
|
||||
require("lpeg")
|
||||
math.randomseed(os.time()+ngx.worker.id())
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
listen ${{PORT}};
|
||||
lua_code_cache ${{CODE_CACHE}};
|
||||
|
||||
# nginx-rtmp hls and status endpoints
|
||||
location /hls {
|
||||
types {
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
video/mp2t ts;
|
||||
}
|
||||
root /opt/data;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
location /live {
|
||||
alias /opt/data/hls;
|
||||
types {
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
video/mp2t ts;
|
||||
}
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
location /stat {
|
||||
rtmp_stat all;
|
||||
rtmp_stat_stylesheet static/stat.xsl;
|
||||
}
|
||||
|
||||
location /static {
|
||||
alias static;
|
||||
}
|
||||
|
||||
location = /crossdomain.xml {
|
||||
root static;
|
||||
default_type text/xml;
|
||||
expires 24h;
|
||||
}
|
||||
|
||||
# lapis endpoints
|
||||
location /data/ {
|
||||
root /mnt;
|
||||
}
|
||||
|
||||
location / {
|
||||
default_type text/html;
|
||||
content_by_lua_block {
|
||||
require("lapis").serve("app")
|
||||
}
|
||||
}
|
||||
|
||||
location /favicon.ico {
|
||||
alias static/favicon.ico;
|
||||
}
|
||||
}
|
||||
}
|
||||
356
code/static/stat.xsl
Normal file
356
code/static/stat.xsl
Normal file
@ -0,0 +1,356 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
|
||||
<!--
|
||||
Copyright (C) Roman Arutyunyan
|
||||
-->
|
||||
|
||||
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<title>RTMP statistics</title>
|
||||
</head>
|
||||
<body>
|
||||
<xsl:apply-templates select="rtmp"/>
|
||||
<hr/>
|
||||
Generated by <a href='https://github.com/arut/nginx-rtmp-module'>
|
||||
nginx-rtmp-module</a> <xsl:value-of select="/rtmp/nginx_rtmp_version"/>,
|
||||
<a href="http://nginx.org">nginx</a> <xsl:value-of select="/rtmp/nginx_version"/>,
|
||||
pid <xsl:value-of select="/rtmp/pid"/>,
|
||||
built <xsl:value-of select="/rtmp/built"/> <xsl:value-of select="/rtmp/compiler"/>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rtmp">
|
||||
<table cellspacing="1" cellpadding="5">
|
||||
<tr bgcolor="#999999">
|
||||
<th>RTMP</th>
|
||||
<th>#clients</th>
|
||||
<th colspan="4">Video</th>
|
||||
<th colspan="4">Audio</th>
|
||||
<th>In bytes</th>
|
||||
<th>Out bytes</th>
|
||||
<th>In bits/s</th>
|
||||
<th>Out bits/s</th>
|
||||
<th>State</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">Accepted: <xsl:value-of select="naccepted"/></td>
|
||||
<th bgcolor="#999999">codec</th>
|
||||
<th bgcolor="#999999">bits/s</th>
|
||||
<th bgcolor="#999999">size</th>
|
||||
<th bgcolor="#999999">fps</th>
|
||||
<th bgcolor="#999999">codec</th>
|
||||
<th bgcolor="#999999">bits/s</th>
|
||||
<th bgcolor="#999999">freq</th>
|
||||
<th bgcolor="#999999">chan</th>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bytes_in"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bytes_out"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_in"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_out"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td/>
|
||||
<td>
|
||||
<xsl:call-template name="showtime">
|
||||
<xsl:with-param name="time" select="/rtmp/uptime * 1000"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="server"/>
|
||||
</table>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="server">
|
||||
<xsl:apply-templates select="application"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="application">
|
||||
<tr bgcolor="#999999">
|
||||
<td>
|
||||
<b><xsl:value-of select="name"/></b>
|
||||
</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="live"/>
|
||||
<xsl:apply-templates select="play"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="live">
|
||||
<tr bgcolor="#aaaaaa">
|
||||
<td>
|
||||
<i>live streams</i>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<xsl:value-of select="nclients"/>
|
||||
</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="stream"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="play">
|
||||
<tr bgcolor="#aaaaaa">
|
||||
<td>
|
||||
<i>vod streams</i>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<xsl:value-of select="nclients"/>
|
||||
</td>
|
||||
</tr>
|
||||
<xsl:apply-templates select="stream"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="stream">
|
||||
<tr valign="top">
|
||||
<xsl:attribute name="bgcolor">
|
||||
<xsl:choose>
|
||||
<xsl:when test="active">#cccccc</xsl:when>
|
||||
<xsl:otherwise>#dddddd</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<td>
|
||||
<a href="">
|
||||
<xsl:attribute name="onclick">
|
||||
var d=document.getElementById('<xsl:value-of select="../../name"/>-<xsl:value-of select="name"/>');
|
||||
d.style.display=d.style.display=='none'?'':'none';
|
||||
return false
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="name"/>
|
||||
<xsl:if test="string-length(name) = 0">
|
||||
[EMPTY]
|
||||
</xsl:if>
|
||||
</a>
|
||||
</td>
|
||||
<td align="middle"> <xsl:value-of select="nclients"/> </td>
|
||||
<td>
|
||||
<xsl:value-of select="meta/video/codec"/> <xsl:value-of select="meta/video/profile"/> <xsl:value-of select="meta/video/level"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_video"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:apply-templates select="meta/video/width"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="meta/video/frame_rate"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="meta/audio/codec"/> <xsl:value-of select="meta/audio/profile"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_audio"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:apply-templates select="meta/audio/sample_rate"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="meta/audio/channels"/>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bytes_in"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bytes_out"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_in"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td>
|
||||
<xsl:call-template name="showsize">
|
||||
<xsl:with-param name="size" select="bw_out"/>
|
||||
<xsl:with-param name="bits" select="1"/>
|
||||
<xsl:with-param name="persec" select="1"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
<td><xsl:call-template name="streamstate"/></td>
|
||||
<td>
|
||||
<xsl:call-template name="showtime">
|
||||
<xsl:with-param name="time" select="time"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:none">
|
||||
<xsl:attribute name="id">
|
||||
<xsl:value-of select="../../name"/>-<xsl:value-of select="name"/>
|
||||
</xsl:attribute>
|
||||
<td colspan="16" ngcolor="#eeeeee">
|
||||
<table cellspacing="1" cellpadding="5">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>State</th>
|
||||
<th>Address</th>
|
||||
<th>Flash version</th>
|
||||
<th>Page URL</th>
|
||||
<th>SWF URL</th>
|
||||
<th>Dropped</th>
|
||||
<th>Timestamp</th>
|
||||
<th>A-V</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<xsl:apply-templates select="client"/>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="showtime">
|
||||
<xsl:param name="time"/>
|
||||
|
||||
<xsl:if test="$time > 0">
|
||||
<xsl:variable name="sec">
|
||||
<xsl:value-of select="floor($time div 1000)"/>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:if test="$sec >= 86400">
|
||||
<xsl:value-of select="floor($sec div 86400)"/>d
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$sec >= 3600">
|
||||
<xsl:value-of select="(floor($sec div 3600)) mod 24"/>h
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="$sec >= 60">
|
||||
<xsl:value-of select="(floor($sec div 60)) mod 60"/>m
|
||||
</xsl:if>
|
||||
|
||||
<xsl:value-of select="$sec mod 60"/>s
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="showsize">
|
||||
<xsl:param name="size"/>
|
||||
<xsl:param name="bits" select="0" />
|
||||
<xsl:param name="persec" select="0" />
|
||||
<xsl:variable name="sizen">
|
||||
<xsl:value-of select="floor($size div 1024)"/>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$sizen >= 1073741824">
|
||||
<xsl:value-of select="format-number($sizen div 1073741824,'#.###')"/> T</xsl:when>
|
||||
|
||||
<xsl:when test="$sizen >= 1048576">
|
||||
<xsl:value-of select="format-number($sizen div 1048576,'#.###')"/> G</xsl:when>
|
||||
|
||||
<xsl:when test="$sizen >= 1024">
|
||||
<xsl:value-of select="format-number($sizen div 1024,'#.##')"/> M</xsl:when>
|
||||
<xsl:when test="$sizen >= 0">
|
||||
<xsl:value-of select="$sizen"/> K</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:if test="string-length($size) > 0">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$bits = 1">b</xsl:when>
|
||||
<xsl:otherwise>B</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="$persec = 1">/s</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="streamstate">
|
||||
<xsl:choose>
|
||||
<xsl:when test="active">active</xsl:when>
|
||||
<xsl:otherwise>idle</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template name="clientstate">
|
||||
<xsl:choose>
|
||||
<xsl:when test="publishing">publishing</xsl:when>
|
||||
<xsl:otherwise>playing</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="client">
|
||||
<tr>
|
||||
<xsl:attribute name="bgcolor">
|
||||
<xsl:choose>
|
||||
<xsl:when test="publishing">#cccccc</xsl:when>
|
||||
<xsl:otherwise>#eeeeee</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:attribute>
|
||||
<td><xsl:value-of select="id"/></td>
|
||||
<td><xsl:call-template name="clientstate"/></td>
|
||||
<td>
|
||||
<a target="_blank">
|
||||
<xsl:attribute name="href">
|
||||
http://apps.db.ripe.net/search/query.html?searchtext=<xsl:value-of select="address"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="title">whois</xsl:attribute>
|
||||
<xsl:value-of select="address"/>
|
||||
</a>
|
||||
</td>
|
||||
<td><xsl:value-of select="flashver"/></td>
|
||||
<td>
|
||||
<a target="_blank">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="pageurl"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="pageurl"/>
|
||||
</a>
|
||||
</td>
|
||||
<td><xsl:value-of select="swfurl"/></td>
|
||||
<td><xsl:value-of select="dropped"/></td>
|
||||
<td><xsl:value-of select="timestamp"/></td>
|
||||
<td><xsl:value-of select="avsync"/></td>
|
||||
<td>
|
||||
<xsl:call-template name="showtime">
|
||||
<xsl:with-param name="time" select="time"/>
|
||||
</xsl:call-template>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="publishing">
|
||||
publishing
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="active">
|
||||
active
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="width">
|
||||
<xsl:value-of select="."/>x<xsl:value-of select="../height"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
11
code/views/layout.etlua
Normal file
11
code/views/layout.etlua
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Puikheid</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body class="body">
|
||||
<% content_for("inner") %>
|
||||
</body>
|
||||
</html>
|
||||
5
code/views/root.etlua
Normal file
5
code/views/root.etlua
Normal file
@ -0,0 +1,5 @@
|
||||
<div class="root">
|
||||
<video autoplay muted loop id="puikheid" style="position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%;">
|
||||
<source src="data/play-tv.mp4" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
17
docker-compose-local.yml
Normal file
17
docker-compose-local.yml
Normal file
@ -0,0 +1,17 @@
|
||||
version: "3.3"
|
||||
services:
|
||||
wasted.audio:
|
||||
build: .
|
||||
networks:
|
||||
- web
|
||||
volumes:
|
||||
- ./code:/srv/lapis
|
||||
- ./_assets:/mnt/data
|
||||
ports:
|
||||
- "8082:8080"
|
||||
- "1935:1935"
|
||||
|
||||
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal file
@ -0,0 +1,30 @@
|
||||
version: "3.3"
|
||||
services:
|
||||
puikheid:
|
||||
environment:
|
||||
- ENVIRONMENT
|
||||
build: .
|
||||
networks:
|
||||
- web
|
||||
volumes:
|
||||
- ./code:/srv/lapis
|
||||
- /media/puikheid.nl:/mnt/data
|
||||
ports:
|
||||
- "1935:1935"
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.http.routers.trackdb.rule=Host(`puikheid.nl`)
|
||||
- traefik.http.routers.trackdb.entrypoints=web
|
||||
- traefik.http.routers.trackdb.middlewares=redirect-https-trackdb
|
||||
- traefik.http.middlewares.redirect-https-trackdb.redirectscheme.scheme=https
|
||||
|
||||
- traefik.http.routers.trackdb_ssl.rule=Host(`puikheid.nl`)
|
||||
- traefik.http.routers.trackdb_ssl.entrypoints=websecure
|
||||
- traefik.http.routers.trackdb_ssl.tls.certresolver=myresolver
|
||||
|
||||
- traefik.http.services.trackdb.loadbalancer.server.port=8080
|
||||
|
||||
|
||||
networks:
|
||||
web:
|
||||
external: true
|
||||
Loading…
Reference in New Issue
Block a user