Add turn server; Configure mirotalk to use turn;
This commit is contained in:
1 parent
374428658a
commit
6bb9ceefb8
6 files changed
+110
-7
No files matched your search
@@ -22,6 +22,7 @@ in
|
||||
./pocket-id
|
||||
./seafile
|
||||
./stalwart
|
||||
./turn
|
||||
./vaultwarden
|
||||
./zapret2
|
||||
./zerobyte
|
||||
@@ -151,14 +152,21 @@ in
|
||||
};
|
||||
};
|
||||
mirotalk = {
|
||||
enable = false;
|
||||
enable = true;
|
||||
targetName = "mirotalk";
|
||||
server = {
|
||||
name = "mirotalk-server";
|
||||
subdomain = "meet";
|
||||
hostHttpPort = 6030;
|
||||
hostHttpPort = 5110;
|
||||
};
|
||||
};
|
||||
turn = {
|
||||
enable = true;
|
||||
name = "turn-server";
|
||||
listenPort = 3479;
|
||||
minPort = 49160;
|
||||
maxPort = 49200;
|
||||
};
|
||||
netbird = {
|
||||
enable = true;
|
||||
targetName = "netbird";
|
||||
|
||||
@@ -27,7 +27,7 @@ in
|
||||
OIDC_AUTH_LOGOUT=true
|
||||
SESSION_SECRET=${config.sops.placeholder."mirotalk/session_secret"}
|
||||
|
||||
HOST_PROTECTED=true
|
||||
HOST_PROTECTED=false
|
||||
HOST_USER_AUTH=false
|
||||
HOST_USERS='[]'
|
||||
|
||||
@@ -35,8 +35,12 @@ in
|
||||
|
||||
STUN_SERVER_ENABLED=true
|
||||
STUN_SERVER_URL=${stunUrl}
|
||||
TURN_SERVER_ENABLED=false
|
||||
TURN_SERVER_ENABLED=true
|
||||
TURN_SERVER_URL=turn:${config.selfhosted.netbird.subdomain}.${domain}:${toString config.selfhosted.turn.listenPort}
|
||||
TURN_SERVER_USERNAME=turn
|
||||
TURN_SERVER_CREDENTIAL=${config.sops.placeholder."turn/password"}
|
||||
|
||||
SHOW_ACTIVE_ROOMS=true
|
||||
STATS_ENABLED=false
|
||||
SURVEY_ENABLED=false
|
||||
'';
|
||||
|
||||
@@ -22,8 +22,7 @@ in
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
||||
# Docker Hub only publishes `latest`; this digest is MiroTalk P2P 1.9.39 (2026-09-03).
|
||||
image = "docker.io/mirotalk/p2p@sha256:c05675e2e3e8a2bb1ee63f07dcaaf8523a30b4dee4d1e594594ff5e36c959b07";
|
||||
image = "docker.io/mirotalk/p2p@sha256:c05675e2e3e8a2bb1ee63f07dcaaf8523a30b4dee4d1e594594ff5e36c959b07"; # 1.9.39 (2026-09-03)
|
||||
ports = [
|
||||
"0.0.0.0:${toString cfg.hostHttpPort}:3000"
|
||||
];
|
||||
@@ -44,6 +43,9 @@ in
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
after = lib.optionals config.selfhosted.turn.enable [
|
||||
"${common.backend}-${config.selfhosted.turn.name}.service"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.selfhosted.turn;
|
||||
domain = "${config.sops.placeholder."domains/serv"}";
|
||||
realm = "${config.selfhosted.netbird.subdomain}.${domain}";
|
||||
in
|
||||
{
|
||||
config = mkIf cfg.enable {
|
||||
sops.secrets = {
|
||||
"turn/password" = { };
|
||||
"turn/public-ip" = { };
|
||||
};
|
||||
|
||||
sops.templates."turnserver.conf".content = ''
|
||||
listening-port=${toString cfg.listenPort}
|
||||
fingerprint
|
||||
lt-cred-mech
|
||||
realm=${realm}
|
||||
user=turn:${config.sops.placeholder."turn/password"}
|
||||
min-port=${toString cfg.minPort}
|
||||
max-port=${toString cfg.maxPort}
|
||||
external-ip=${config.sops.placeholder."turn/public-ip"}
|
||||
log-file=stdout
|
||||
no-cli
|
||||
no-tls
|
||||
no-dtls
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.turn;
|
||||
in
|
||||
{
|
||||
imports = [ ./config.nix ];
|
||||
|
||||
options.selfhosted.turn = {
|
||||
enable = mkEnableOption "Enable coturn server";
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
listenPort = mkOption {
|
||||
type = types.port;
|
||||
};
|
||||
minPort = mkOption {
|
||||
type = types.port;
|
||||
};
|
||||
maxPort = mkOption {
|
||||
type = types.port;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
virtualisation.oci-containers.containers.${cfg.name} = {
|
||||
image = "docker.io/coturn/coturn:4.6.3";
|
||||
cmd = [ "-c" "/etc/turnserver.conf" ];
|
||||
ports =
|
||||
[ "0.0.0.0:${toString cfg.listenPort}:${toString cfg.listenPort}/udp" ]
|
||||
++ map (port: "0.0.0.0:${toString port}:${toString port}/udp") (
|
||||
range cfg.minPort cfg.maxPort
|
||||
);
|
||||
volumes = [ "${config.sops.templates."turnserver.conf".path}:/etc/turnserver.conf:ro" ];
|
||||
log-driver = "journald";
|
||||
extraOptions = [ "--network=${common.network.name}" ];
|
||||
};
|
||||
|
||||
systemd.services."${common.backend}-${cfg.name}" = {
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
after = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user