Managed TURN via Cloudflare (recommended)
Cloudflare’s Realtime TURN service runs on Cloudflare’s global anycast network. It needs no public IP, no UDP port range, and no TLS certificates on your side, and it includes a generous free tier.1
Create a TURN key
In the Cloudflare dashboard, open Realtime > TURN Server and create a key. Copy the Turn Token ID and its API token (the token is shown only once).
2
Set the server environment
In The signaling server mints short-lived ICE credentials from Cloudflare and caches them. These variables take precedence over the coturn variables below, so you do not need to run coturn.
.env:Self-hosting with coturn
Prefer to run the relay yourself? Leave the Cloudflare variables unset and configure coturn instead. TURN requires a public IP address, a domain name, and TLS certificates. The bundledcoturn service uses host networking and is intended for a Linux host with a public IP.
Setup
1
Create the coturn config
coturn/turnserver.conf and set:static-auth-secretto a strong random value (e.g.openssl rand -hex 32)realmto your TURN hostname (e.g.turn.your-domain.com)certandpkeyto the paths of your TLS certificate and key
docker-compose.yml for how to make certificates available inside the container.2
Match the server environment
In The signaling server uses these to issue time-limited HMAC-SHA1 credentials for coturn. Credentials expire after 24 hours.
.env:3
Open firewall ports
On the host, open the following ports:
4
Start the stack with the TURN profile
Verify
Check that the signaling server returns TURN credentials:turn: and turns: entries, plus a stun: entry pointing at your TURN host:
turn.cloudflare.com entries. When neither the Cloudflare variables nor TURN_SECRET / TURN_DOMAIN are set, the endpoint returns the Google public STUN servers only.
How credentials work
The signaling server generates time-limited credentials using HMAC-SHA1. The username is{expiry_unix_timestamp}:floeuser and the password is base64(HMAC-SHA1(TURN_SECRET, username)). coturn validates these against the shared secret without needing a database of user accounts.