2024-09-10 15:15:08 -04:00
|
|
|
{outputs, config, ...}: {
|
2024-09-10 15:07:31 -04:00
|
|
|
services = {
|
|
|
|
coturn = rec {
|
|
|
|
enable = true;
|
|
|
|
no-cli = true;
|
|
|
|
no-tcp-relay = true;
|
|
|
|
min-port = 49000;
|
|
|
|
max-port = 50000;
|
|
|
|
use-auth-secret = true;
|
|
|
|
static-auth-secret = "will be world readable for local users :(";
|
|
|
|
realm = "turn.${outputs.secrets.jimDomain}";
|
|
|
|
cert = "/var/lib/acme/turn.${outputs.secrets.jimDomain}.com/fullchain.pem";
|
|
|
|
pkey = "/var/lib/acme/turn.${outputs.secrets.jimDomain}.com/key.pem";
|
|
|
|
};
|
|
|
|
|
2024-09-10 15:10:58 -04:00
|
|
|
# Enable coturn on Synapse
|
|
|
|
matrix-synapse.settings = {
|
|
|
|
turn_uris = [
|
|
|
|
"turn:turn.${outputs.secrets.jimDomain}:3478?transport=udp"
|
|
|
|
"turn:turn.${outputs.secrets.jimDomain}:3478?transport=tcp"
|
|
|
|
];
|
2024-09-10 15:15:08 -04:00
|
|
|
turn_shared_secret = config.services.coturn.static-auth-secret;
|
2024-09-10 15:10:58 -04:00
|
|
|
turn_user_lifetime = "1h";
|
|
|
|
};
|
|
|
|
|
2024-09-10 15:07:31 -04:00
|
|
|
# Proxy main coturn port
|
|
|
|
nginx.virtualHosts."turn.${outputs.secrets.jimDomain}" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
listen = [{
|
|
|
|
addr = "0.0.0.0";
|
|
|
|
port = 80;
|
|
|
|
ssl = false;
|
|
|
|
}];
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:1380";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Open coturn ports
|
|
|
|
networking.firewall = {
|
|
|
|
allowedUDPPorts = [
|
|
|
|
3478 5349
|
|
|
|
];
|
|
|
|
allowedUDPPortRanges = [
|
|
|
|
{ from = 49000; to = 50000; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|