Turn Server

Learn how to host your own turn server!

Why do I need this? If you are in China or you only see black screens in monitoring, you may need this.

What is it? A TURN server helps devices communicate over the internet when direct connections are blocked by firewalls or NAT. It relays data between devices, ensuring smooth connections for apps like video calls or messaging.

Example Usage With Luxu Admin (After install)

šŸ“config/api.json

"custom_ice_servers": [
    {
            urls = "turn:37.100.40.100:3478",
            username = "luxu",
            credential = "gg",
     }
  ],

Cloudflare Turn Server (Free Option)

Open account in https://cloudflare.com and create a free turn server.

It will create an turn token id and api token, which you must save securely.

Add these tokens to api.json cloudflare_turn_keys

The admin menu will automaticaly generate the servers at runtime.

Full Documentation: https://developers.cloudflare.com/realtime/turn/

image.png

image.png

image.png

Manual self hosting (Best option if you have good VPS)

In this guide we will install Go and pion turn server

Requirements:

Golang installation

Windows

Go to All releases - The Go Programming Language

Download and install the correct build for your machine:

Examples:

  • Windows (non arm): go1.25.5.windows-amd64.msi

Linux

Install command: sudo apt update && sudo apt -y install golang-go

Pion Turn server

After you install golang in your machine, we will download pion turn server

  1. Go to https://github.com/pion/turn/releases

  2. Download the source code from the latest release

  3. Unzip the file

  4. Open the terminal inside the folder (e.g. turn-4.1.3)

  5. Navigate to turn-server folder inside examples

    1. cd examples/turn-server
  6. Build the simple folder into a executable

    1. go build ./simple
  7. Start your turn server with the following configuration (change the ip to your vps ip and change the username=password with something you choose e.g. luxu=gg

    Windows

    ./simple.exe -port 3478 -public-ip YOUR_SERVER_IP -users luxu=gg

    Linux

    ./simple -port 3478 -public-ip YOUR_SERVER_IP -users luxu=gg
  8. Your Turn server should now be available to use in any resource you want!

  9. (Optional) Make a .bat file to easily restart your server e.g.

    1. Configure the following script
    @echo off
    cd /d "path\to\your\folder"
    echo Turn server started!
    simple.exe -port 3478 -public-ip YOUR_SERVER_IP -users username=password
    pause