# Rendered by install.sh/hydrate.sh → /etc/oxpulse-partner-edge/coturn.conf # DO NOT EDIT DIRECTLY — regenerated on reinstall / upgrade. # # Placeholders (substituted at render time): # {{TURN_SECRET}} {{PARTNER_DOMAIN}} {{TURNS_SUBDOMAIN}} # {{PUBLIC_IP}} {{EXTERNAL_IP_LINE}} # # Architecture (v0.2.0+): # - TLS enabled on 5349 — caddy-l4 proxies TURNS:443 → 127.0.0.1:5349 (host network) # - Cert issued by Caddy via ACME HTTP-01 for {{TURNS_SUBDOMAIN}}.{{PARTNER_DOMAIN}}, # shared with coturn via read-only docker volume mount (see docker-compose.yml.tpl) # - SIGUSR2 reloads cert without session drop (verified in coturn source # mainrelay.c:3422 → reload_ssl_certs handler) # ─── Ports ────────────────────────────────────────────────────────────── listening-port=3478 alt-listening-port=3479 tls-listening-port=5349 # ─── Auth: HMAC shared-secret (RFC 7635) ──────────────────────────────── fingerprint lt-cred-mech use-auth-secret static-auth-secret={{TURN_SECRET}} realm={{PARTNER_DOMAIN}} # ─── Capacity / rate limits (R1 §5.3) ─────────────────────────────────── # Sized for ~100 concurrent calls. Each call has ~2 TURN channels. total-quota=250 # Per-credential cap. Must exceed a single client's interface count — WebRTC # relay-policy clients allocate one relay per local interface (IPv4 + IPv6 + VPN) # under one ephemeral username; user-quota=4 caused 486 Allocation Quota Reached # and broke relay-only (RU) calls. 16 gives headroom; total-quota still bounds the box. user-quota=16 # Bandwidth cap per session: 2 Mbps (video call at 1080p30 peaks ~1.5 Mbps). max-bps=250000 # Total server bandwidth cap: 200 Mbps conservative. bps-capacity=25000000 stale-nonce=600 # Allocation lifetime cap: prevents leaked allocations from wedging user-quota. # When the coturn probe (channel-health-lib.sh) times out on a dead relay, the # turnutils_uclient process is killed (exit 124) without sending TURN Refresh(0) # (graceful dealloc), so coturn holds 2 dangling allocations per probe tick until # they expire. max-allocate-lifetime caps a Refresh to 120s. (The default # allocation lifetime, 600s, is fixed — coturn has no allocation-default-timeout # option in any version; a line setting it only logs "Bad configuration format".) # Root cause fix: OXPULSE_COTURN_PROBE_TARGET (avoid hairpin). max-allocate-lifetime=120 # ─── Peer policy ──────────────────────────────────────────────────────── # Loopback peers are refused by coturn by default and by denied-peer-ip # 127.0.0.0/8 below. There is no `no-loopback-peers` option; the real knob is # `allow-loopback-peers`, which stays UNSET. no-multicast-peers no-tcp-relay # R1 Layer 2: suppress STUN NAT-behavior-discovery response to active probers. no-rfc5780 # ─── TLS cert / cipher hardening ──────────────────────────────────────── # Cert path inside the coturn container — Caddy's named volume mounted read-only # at /data/caddy (see docker-compose.yml.tpl in Task 2A.4). Caddy's cert storage # layout for ACME HTTP-01 issuer is documented + stable across Caddy 2.x. cert=/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/{{TURNS_SUBDOMAIN}}.{{PARTNER_DOMAIN}}/{{TURNS_SUBDOMAIN}}.{{PARTNER_DOMAIN}}.crt pkey=/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/{{TURNS_SUBDOMAIN}}.{{PARTNER_DOMAIN}}/{{TURNS_SUBDOMAIN}}.{{PARTNER_DOMAIN}}.key # TLS version floor (R1 §5.5). # LEGACY-4.6-COMPAT (see the LEGACY-4.6-COMPAT block below): required on 4.6.x, which # allows TLS 1.0/1.1 without them; coturn >= 4.18 has them off by default and logs # `WARNING Bad configuration format` for these two keys (harmless). no-tlsv1 no-tlsv1_1 # Cipher-list aligned with Caddy/Go defaults — narrows JA3S divergence between # Caddy and coturn TLS stacks (design §4.2 Conflict 2). Not perfect alignment # (extension ordering + GREASE differ), but narrows flaggable anomaly surface. cipher-list="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384" # LEGACY-4.6-COMPAT: `no-dtls`, `no-tlsv1`, `no-tlsv1_1` and `no-cli` are options # of coturn 4.6.x only. This conf is rendered BEFORE the image is pulled and can be # read by a still-4.6 container (rollback, a restart in the upgrade window, an edge # not yet on 4.18), and on 4.6 their ABSENCE silently means DTLS on 5349/udp (against # the anti-probing posture), the telnet CLI on 127.0.0.1:5766 and TLS 1.0/1.1. On # 4.18 they are inert: unknown keys log a WARNING ("Bad configuration format", not # fatal; no-cli logs a deprecated ERROR line) and DTLS / CLI / TLS 1.0-1.1 are off by # default. A conf that is safe on BOTH binaries beats a version-aware render, whose # failure mode (a misread version) is the silent insecure one. Removal: once every # edge runs >= 4.18 (fleet-versions check), drop these four lines and flip the # tests/test_coturn_config.sh legacy-lines assertion; never add `dtls` or `cli`. no-dtls # ─── Anti-SSRF denied-peer-ip (IPv4 + IPv6) ───────────────────────────── # Source: BBB template via scratch/C §BBB + scratch/B §3 IPv6 additions. denied-peer-ip=0.0.0.0-0.255.255.255 denied-peer-ip=10.0.0.0-10.255.255.255 denied-peer-ip=100.64.0.0-100.127.255.255 denied-peer-ip=127.0.0.0-127.255.255.255 denied-peer-ip=169.254.0.0-169.254.255.255 denied-peer-ip=172.16.0.0-172.31.255.255 denied-peer-ip=192.0.0.0-192.0.0.255 denied-peer-ip=192.0.2.0-192.0.2.255 denied-peer-ip=192.168.0.0-192.168.255.255 denied-peer-ip=198.18.0.0-198.19.255.255 denied-peer-ip=198.51.100.0-198.51.100.255 denied-peer-ip=203.0.113.0-203.0.113.255 denied-peer-ip=224.0.0.0-239.255.255.255 denied-peer-ip=240.0.0.0-255.255.255.255 # IPv6 (coturn A-B range syntax, not CIDR) denied-peer-ip=::1 denied-peer-ip=::ffff:0.0.0.0-::ffff:255.255.255.255 denied-peer-ip=fc00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff denied-peer-ip=fe80::-febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff # NAT64 well-known prefix 64:ff9b::/96 embeds an IPv4 address (GHSA-2x4g): without # this, a peer 64:ff9b::a00:1 reaches 10.0.0.1 through a NAT64 gateway. Harmless # where IPv6 relay is unused. denied-peer-ip=64:ff9b::-64:ff9b::ffff:ffff # ─── Co-located SFU / host-local peers ────────────────────────────────── # EXACTLY ONE allowed-peer-ip, and only on a NAT'd edge: this host's OWN relay # address (the private half of external-ip). Without it coturn applies the # denied-peer-ip 10.0.0.0/8 block above to its own relay address, and same-edge # relaying fails ("channel bind: error 403 Forbidden IP") — two relay-forced # clients on one edge, and client -> co-located SFU via TURN (the peer is mapped to # the relay address). Never any other address: nothing relays from a secondary # local IP, and a non-local one would be SSRF to that host, which the nft guard # (local addresses only) does not cover. The address must be LOCAL: the guard's conf # migration and `status` refuse a stale (non-local) one. # What coturn may then SEND to its own address is decided by the host nft table # coturn_self_relay_guard (oxpulse-partner-edge-coturn-guard, keyed on this # container's fixed uid): the SFU media port and the relay range, nothing else — # that is what makes allowing the host's own address safe. # Rendered empty on a public-NIC edge (no private address). `guard status` and the # guard's conf migration enforce "own address only". {{ALLOWED_PEER_IP_LINE}} # ─── Relay port range ─────────────────────────────────────────────────── # MUST equal, everywhere: RELAY_MIN/RELAY_MAX in oxpulse-partner-edge-coturn-guard.sh # (which reserves the range from the kernel ephemeral pool via # net.ipv4.ip_local_reserved_ports and lets the nft guard treat "local + inside # this range" as a coturn relay socket) and _PE_FW_PUB_UDP_RANGES in # lib/firewall-lib.sh (+ its frozen twin lib/install-firewall.sh). # tests/test_coturn_guard.sh fails if any of them drifts. # 49152-49999 = 848 ports; one allocation holds one port (no-rfc5780, no RTP/RTCP # pairing), and total-quota=250 caps concurrent allocations — ample headroom. min-port=49152 max-port=49999 external-ip={{EXTERNAL_IP_LINE}} # ─── Logging ──────────────────────────────────────────────────────────── log-file=/var/log/turnserver/turn.log pidfile=/var/run/turnserver/turnserver.pid no-stdout-log simple-log syslog # LEGACY-4.6-COMPAT (see above): 4.6 starts the telnet CLI unless told not to; 4.18 # logs "ERROR no-cli option is deprecated" for it (non-fatal; the CLI is off by # default there). no-cli