Skip to content

Livekit remote server setup

This setup guide assumes the installation is performed on an ubuntu machine via Cloud Init. Some additional information can be found at https://docs.livekit.io/home/self-hosting/vm/.

Step 1: Create the configuration file cloud_init.ubuntu.yaml.

In order to do so, we have to run the following command in an ubuntu environment with Docker installed. Ideally, in one of the existing Livekit servers we are using.

docker pull livekit/generate
docker run --rm -it -v$PWD:/output livekit/generate

Step 2: Follow the configuration instructions

After running the aforementioned commands, you will be prompted to insert the following: - A domain for the livekit server - A domain for the livekit turn server - Whether to include Egress/Ingress - Whether to boundle Redis - Whether to use easyencrypt or external SSL

The domains should be A records that we'll later point to the server IP. We want to include Egress and boundle Redis. For now, we use easyencrypt.

At the end of the configuration you will be provided with Server URL, API Key and API Secret. Note them down!

Step 3: Using the cloud_init.ubuntu.yaml

Depending on the provider, you'll be asked to provide the cloud_init file or its contents. At the end of the previous configuration step you should be told where the cloud_init file was created. As of today, it is generated at "SERVER_DOMAIN/cloud_init.ubuntu.yaml", where server-domain is the choosen domain for the livekit server in the previous step.

Once the server is successfully deployed, Livekit should automatically be installed and running.

Step 4: Create the A records

Now that we have an IP address for the server, we need to create the two A Records for livekit and and livekit turn servers.

Step 5 (Optional): Update .bashrc

On a fresh server, if we want to add colors to the terminal, we can append this code to the .bashrc file:

GREEN='\[\033[01;32m\]'
RED='\[\033[01;31m\]'
RESET='\[\033[00m\]'

# Determine instance name color based on user
if [ "$(id -u)" -eq 0 ]; then
    INSTANCE_COLOR=$RED
    INSTANCE_NAME="root-instance"
else
    INSTANCE_COLOR=$GREEN
    INSTANCE_NAME="user-instance"
fi

# Set the prompt format with colored instance name
PS1="${GREEN}\u@${RED}\h${RESET}:${GREEN}\w${RESET}\$ "
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/livekit-backend-go/go/bin

Step 6: Verify everything went well

docker ps should tell you if the containers are up and running. systemctl status livekit-docker should tell you more info about the current status of the container/service.

Finally, to verify further you can do the following: cd /opt/livekit sudo docker-compose logs

Among these logs you should also try to find out whether SSL certificates were successfully created. The line should look like this:

livekit-caddy-1    | 
{"level":"info","ts":1642786068.3883107,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"<yourhost>"}

Step 7: Adapting Caddy to the backend configuration

In order to be able to route the traffic to our backend, we also need to edit the caddy.yaml file with the additional routes of the current version of the backend.

(Also egress.yaml with servers with low cpu cores, add line "room_composite_cpu_cost: 0.5")

( Add "- ./recordings:/out" under volume of the docker-compose.yaml until we use S3)