Skip to content

Deploying

Deploying

One host, one binary:

CGO_ENABLED=0 go install github.com/go-turn/turn/cmd/turnd@latest

Ports

Open these at the host firewall and at the cloud security group:

portfor
UDP 3478STUN and TURN over UDP (--stun-listen :3478)
TCP 3478TURN over TCP (--turn-tcp-listen :3478)
TCP 5349TURN over TLS (--turns-listen :5349), for networks that block UDP
UDP rangerelayed addresses (--relay-port-min 49160 --relay-port-max 49999)
TCP 443HTTPS: /login, /callback, /grpc, through the host’s reverse proxy to --listen 127.0.0.1:8080 (the proxy must pass WebSocket upgrades)

To share 443 between that HTTPS site and TURN over TLS, see TURN over TLS on 443.

The HTTP half

turnd --issuer https://login.example.org --client-id turnd \
  --client-secret-file /etc/turnd/client-secret \
  --session-key-file /etc/turnd/session.key \
  --turn-secret-file /etc/turnd/turn.secret \
  --allowed-origin https://go-tex.github.io \
  --public-url https://turn.example.org --listen 127.0.0.1:8080 \
  --turn-uri 'turns:turn.example.org:443?transport=tcp'

Register <public-url>/callback as the client’s redirect URI at the issuer (the one named by --client-id).

The relay

turnd starts the relay when a listen flag is set:

flag
--relay-iprequired; --relay-advertise-ip behind a NAT
--stun-listen :3478STUN and TURN over UDP
--turn-tcp-listen :3478TURN over TCP
--turns-listen :443TURN over TLS, with --tls-cert-file and --tls-key-file
--relay-port-min / --relay-port-maxthe range of relayed UDP ports
--proxy-protocol-from <prefix>repeatable; accept a PROXY protocol v2 header on TCP and TLS connections from that prefix

The relay’s credential hook is the keyring’s Auth, so the minted <expiry>:<tag>.<subject> usernames are what it accepts (the tag says which of the rotating secrets signed it).

Secrets

Every secret is a file, refused when world-readable; none is a flag value or an environment variable. Make them readable by the service account only:

flagcontent
--session-key-file32+ random bytes
--turn-secret-file16+ random bytes
--client-secret-filethe issuer’s client secret

Repeat --session-key-file / --turn-secret-file to rotate: the first signs, the others only verify.

After deploying

Prove the relay end to end without an OpenID Connect login: Checking a deployment.