1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 15:02:19 +00:00

Use traefik in docker-compose example

This commit is contained in:
Alexandre Iooss 2020-09-15 09:26:44 +02:00
parent 43a3a85e7a
commit bfb542e8d0
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
5 changed files with 128 additions and 10 deletions

View File

@ -1,23 +1,33 @@
# Example of Docker Compose setup using Traefik reverse proxy
version: '3'
services:
# FIXME: adapt URL in conf
# RTMP to WebRTC server
ovenmediaengine:
image: airensoft/ovenmediaengine:0.10.7
ports:
# WebRTC ICE
- 10000-10005:10000-10005/udp
volumes:
- ./ovenmediaengine/conf/Server.xml:/opt/ovenmediaengine/bin/origin_conf/Server.xml
- ./ovenmediaengine/conf/Server-docker.xml:/opt/ovenmediaengine/bin/origin_conf/Server.xml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.ovenmediaengine.rule=Host(`stream.example.com`) && PathPrefix(`/app/`)"
- "traefik.http.routers.ovenmediaengine.priority=101"
- "traefik.http.services.ovenmediaenfine.loadbalancer.server.port=3333"
# FIXME: relay RTMPS to RTMP, auth RTMP with ghostream and relay HTTPS to ghostream HTTP and ovenmediaengine websocket
# RTMP server that authenticate stream against ghostream
rtmp_server:
image: nginx:1.19.2
ports:
- 1935:1935
- 443:443
- 80:80
volumes:
- ./nginx/nginx-docker.conf:/etc/nginx/nginx.conf:ro
labels:
- "traefik.enable=true"
- "traefik.tcp.routers.rtmp.rule=Host(`stream.example.com`)"
- "traefik.tcp.services.rtmp.loadbalancer.server.port=1925"
# ghostream will serve a HTTP server on 8080
# Ghostream is the web frontend to OvenMediaEngine
ghostream:
build: ../
environment:
@ -27,3 +37,8 @@ services:
- SITE_NAME="Ghostream"
- SITE_HOSTNAME="localhost"
- FAVICON="/favicon.ico"
labels:
- "traefik.enable=true"
- "traefik.http.routers.ghostream.rule=Host(`stream.example.com`)"
- "traefik.http.routers.ghostream.priority=100"
- "traefik.http.services.ghostream.loadbalancer.server.port=8080"

View File

@ -30,7 +30,7 @@ rtmp {
live on;
record off;
push rtmp://127.0.0.1:1915;
on_publish http://127.0.0.1:8080/app/auth;
on_publish http://127.0.0.1:8080/rtmp/auth;
}
}
}

View File

@ -0,0 +1,28 @@
# This file is part of Ghostream
# Copyright (C) 2020 by Crans <roots@crans.org>
# SPDX-License-Identifier: GPL-2.0-or-later
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
# Authenticate then stream RTMP
# This RTMP server will be used when clients play directly RTMPS.
# It also push RTMP stream to OvenMediaEngine to generate WebRTC stream.
rtmp {
server {
listen 0.0.0.0:1925;
chunk_size 4096;
application app {
live on;
record off;
push rtmp://ovenmediaengine:1915;
on_publish http://ghostream:8080/rtmp/auth;
}
}
}

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Server version="7">
<Name>OvenMediaEngine</Name>
<Type>origin</Type>
<IP>*</IP>
<Bind>
<Providers>
<RTMP>
<Port>1915</Port>
</RTMP>
</Providers>
<Publishers>
<WebRTC>
<Signalling>
<Port>3333</Port>
</Signalling>
<IceCandidates>
<IceCandidate>*:10000-10005/udp</IceCandidate>
</IceCandidates>
</WebRTC>
</Publishers>
</Bind>
<VirtualHosts>
<VirtualHost>
<Name>default</Name>
<Domain>
<Names>
<Name>*</Name>
</Names>
</Domain>
<Applications>
<Application>
<Name>app</Name>
<Type>live</Type>
<Encodes>
<Encode>
<Name>opus_only</Name>
<Audio>
<Codec>opus</Codec>
<Bitrate>128000</Bitrate>
<Samplerate>48000</Samplerate>
<Channel>2</Channel>
</Audio>
<Video>
<Bypass>true</Bypass>
</Video>
</Encode>
</Encodes>
<Streams>
<Stream>
<Name>${OriginStreamName}</Name>
<Profiles>
<Profile>opus_only</Profile>
</Profiles>
</Stream>
</Streams>
<Providers>
<RTMP>
<BlockDuplicateStreamName>true</BlockDuplicateStreamName>
</RTMP>
</Providers>
<Publishers>
<ThreadCount>2</ThreadCount>
<WebRTC>
<Timeout>30000</Timeout>
</WebRTC>
</Publishers>
</Application>
</Applications>
</VirtualHost>
</VirtualHosts>
</Server>

View File

@ -18,7 +18,7 @@ def viewer(path):
return render_template('viewer.html', path=path)
@app.route('/app/auth', methods=['POST'])
@app.route('/rtmp/auth', methods=['POST'])
def auth():
"""Authentication on stream start"""
name = request.form.get('name')