Skip to content

lovelinuxalot/traefik-livekit-srs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

traefik-livekit-srs

This repo contains information how to set this config up and run

Information

Service URL Purpose Ports
Traefik https://monitor.flypov.com Frontend proxy 80,
443
LiveKit Server https://lv.flypov.com Chat app 7880 (mapped to 443 port via Traefik),
7881,
7882 (WebRTC)
Redis no url, internal service LiveKit server room keys management 6379 (internal port)
SRS https://srs.flypov.com Streaming server 8080 (HTTP streaming port),
1935 (RTMP Streaming Port),
1985 (HTTP API port),
8000/udp (WebRTC)
Postgres no url, internal service Hasure GraphQL engine metadata and backend storage 5432 (internal port)
Hasura GraphQL https://graphql.flypov.com GraphQL engine 8080 (mapped to 443 port via Traefik)

Procedure

  • Clone the repo to a server

Setting up for Traefik

  • Install the necessary packages
    sudo apt-get install apache2-utils
  • Create a password to secure traefik endpoint. The value of secure_password should be replaced by something else
    htpasswd -nb admin secure_password
  • Copy the output and replace it in the file traefik/traefik_dynamic.toml

Setting up for LiveKit Server

  • Generate initial token config by running the command

    docker run --rm -v$PWD:/output livekit/generate --local
  • Compare the config file in livekit/livekit.yaml and replace the keys section with appropriate key and the value from the output of the above command

  • If the redis password needs to be changed, then please adjust the same password in the docker-compose file in redis section. This is not a problem as redis is not being exposed to the internet and this is a testing app

  • A random token will be generated for the room, when running this command, please keep a note of that, as its required for testing.

  • Run the command to spin up the containers:

    docker-compose up -d
  • Ensure the containers are running by running

    docker ps 
  • If there are 6 containers running, then you are good to go. The containers would be:

    • traefik
    • livekit
    • redis
    • srs
    • postgres
    • graphql

Testing Traefik


Testing Livekit

  • Go to https://livekit.io/connection-test.
  • Enter the following details
    • LiveKit Url: wss://lv.flypov.com
    • Room Tokem: Paste the random Token generated when setting up LiveKit
    • Click Start Test
    • If everything is good, there will be a good response.
    • Please note that during testing you might need to allow audio and video in the browser if they are not allowed by default

Testing SRS

  • On a local machine, run the command

    docker run --rm ossrs/srs:encoder   ffmpeg -re -i ./doc/source.200kbps.768x320.flv -c copy -f flv rtmp://srs.flypov.com/live/livestream
  • This will download the image and start to run.

  • When its running, open VLC > Go to File > Open Network Stream

  • Test the following URLS

  • WebRTC is also enabled on the container, honestly I dont know how to test it, so I have left that to you, if you know how to test it.


Testing GraphQL

  • Go to https://graphql.flypov.com
  • Login with the same credentials created for Traefik, because the same middleware that controls the auth for traefik is reused with this service
  • Once logged in, the GraphQL console is visible

Additional information

  • There are some improvements mentioned here. This is when running in a production system. Since this is testing, I skipped it

  • I have not run livekit and srs at the same time, because this can be CPU intensive when running two servers, So I stopped one and started the other to avoid any performance issues

  • Currently HTTPS proxy for SRS does not support with Traefik. This is actually a problem with Traefik, where regex is not optimal fore replace or redirect of urls. SRS recommeneded HTTPS proxy is NGINX. So for now only http urls work for SRS

  • I took the liberty to connect the postgres database for the GraphQL service. The Database URL to connect is found in the graphql service section in Docker compose file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published