MOD updated nginx+module and added rtmp-token-auth

This commit is contained in:
Jan Stabenow
2017-08-24 22:44:47 +02:00
parent 43cff2fabe
commit 4ad62848c0
7 changed files with 47 additions and 10 deletions

View File

@@ -1,13 +1,15 @@
## Changes from 0.1.0-rc7 to 0.1.0 ## Changes from 0.1.0-rc7 to 0.1.0
* switched to Alpine-Linux * switched to Alpine-Linux
* switched Mutlistage Dockerfiles for AMD64 and ARMHF (req. Docker 17.x) * switched to mutlistage Dockerfiles for AMD64 and ARMHF (req. Docker 17.x) and removed old files
* https://hub.docker.com/r/datarhei/ffmpeg/ * https://hub.docker.com/r/datarhei/ffmpeg/
* https://hub.docker.com/r/datarhei/nginx-rtmp/ * https://hub.docker.com/r/datarhei/nginx-rtmp/
* updated to FFmpeg 3.1.10 * updated to FFmpeg 3.1.10
* updated NPM/Bower packages * updated NPM/Bower packages
* fixed public-ip problem * fixed public-ip problem
* disabled FFmpeg "error-detection" for a vlc-like feeling * disabled FFmpeg "error-detection" for a vlc-like feeling
* added optional rtmp-token-authentification (default is without token. token can be set with env RS_TOKEN or in the live.json config.)
* updated NGINX to 1.13.4 and RTMP-Module to latest dev-version
## Changes from 0.1.0-rc7 to 0.1.0-rc.7.1 ## Changes from 0.1.0-rc7 to 0.1.0-rc.7.1

View File

@@ -1,4 +1,4 @@
FROM datarhei/nginx-rtmp:1.9.9-1.1.7.10 as builder FROM datarhei/nginx-rtmp:1.13.4-dev as builder
FROM node:8.1-alpine FROM node:8.1-alpine

View File

@@ -1,4 +1,4 @@
FROM datarhei/nginx-rtmp:1.9.9-1.1.7.10-armhf as builder FROM datarhei/nginx-rtmp:1.13.4-dev-armhf as builder
FROM resin/raspberry-pi-alpine-node:8.1-slim FROM resin/raspberry-pi-alpine-node:8.1-slim
@@ -6,9 +6,9 @@ MAINTAINER datarhei <info@datarhei.org>
ENV RS_USERNAME=admin \ ENV RS_USERNAME=admin \
RS_PASSWORD=datarhei \ RS_PASSWORD=datarhei \
SRC="/usr/local" \ SRC=/usr/local \
LD_LIBRARY_PATH="/usr/local/lib" \ LD_LIBRARY_PATH=/usr/local/lib \
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe COPY --from=builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe
@@ -27,7 +27,7 @@ RUN apk add --no-cache --update git libssl1.0 pcre && \
npm uninstall -g bower grunt grunt-cli nodemon eslint && \ npm uninstall -g bower grunt grunt-cli nodemon eslint && \
npm prune --production && \ npm prune --production && \
npm cache clean --force && \ npm cache clean --force && \
apk del --purge git && \ apk del --no-cache --purge git && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
rm -rf /tmp/* rm -rf /tmp/*

View File

@@ -3,7 +3,8 @@
"jsondb": "db/v1", "jsondb": "db/v1",
"auth": { "auth": {
"username": "admin", "username": "admin",
"password": "datarhei" "password": "datarhei",
"token": ""
}, },
"ffmpeg": { "ffmpeg": {
"options": { "options": {
@@ -31,7 +32,7 @@
}, },
"monitor": { "monitor": {
"restart_wait": "6000", "restart_wait": "6000",
"retries": 10 "retries": 100
} }
}, },
"nginx": { "nginx": {

View File

@@ -10,6 +10,8 @@ rtmp {
application live { application live {
live on; live on;
idle_streams off; idle_streams off;
on_publish http://127.0.0.1:3000/token;
notify_method get;
} }
application hls { application hls {
live on; live on;
@@ -20,6 +22,8 @@ rtmp {
hls_sync 1ms; hls_sync 1ms;
hls_path /tmp/hls; hls_path /tmp/hls;
idle_streams off; idle_streams off;
on_publish http://127.0.0.1:3000/token;
notify_method get;
} }
} }
} }

View File

@@ -28,8 +28,13 @@ class Restreamer {
*/ */
static generateOutputHLSPath () { static generateOutputHLSPath () {
var nginx = config.nginx.streaming; var nginx = config.nginx.streaming;
var token = process.env.RS_TOKEN || config.auth.token;
return 'rtmp://' + nginx.ip + ':' + nginx.rtmp_port + nginx.rtmp_hls_path + 'live.stream'; if (token != '') {
return 'rtmp://' + nginx.ip + ':' + nginx.rtmp_port + nginx.rtmp_hls_path + 'live.stream' + '?token=' + token;
} else {
return 'rtmp://' + nginx.ip + ':' + nginx.rtmp_port + nginx.rtmp_hls_path + 'live.stream';
}
} }
/** /**

View File

@@ -37,4 +37,29 @@ module.exports = (app) => {
req.session.destroy(); req.session.destroy();
res.end(); res.end();
}); });
/* Handle NGINX-RTMP token */
app.get('/token', (req, res) => {
var token = process.env.RS_TOKEN || auth.token;
if (token != '') {
if (req.query.token == token) {
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end('Authorized');
} else {
res.writeHead(401, {
'Content-Type': 'text/plain'
});
res.end('Unauthorized');
}
} else {
res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end('Authorized');
}
});
}; };