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
|
./pocket-id
|
||||||
./seafile
|
./seafile
|
||||||
./stalwart
|
./stalwart
|
||||||
|
./turn
|
||||||
./vaultwarden
|
./vaultwarden
|
||||||
./zapret2
|
./zapret2
|
||||||
./zerobyte
|
./zerobyte
|
||||||
@@ -151,14 +152,21 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
mirotalk = {
|
mirotalk = {
|
||||||
enable = false;
|
enable = true;
|
||||||
targetName = "mirotalk";
|
targetName = "mirotalk";
|
||||||
server = {
|
server = {
|
||||||
name = "mirotalk-server";
|
name = "mirotalk-server";
|
||||||
subdomain = "meet";
|
subdomain = "meet";
|
||||||
hostHttpPort = 6030;
|
hostHttpPort = 5110;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
turn = {
|
||||||
|
enable = true;
|
||||||
|
name = "turn-server";
|
||||||
|
listenPort = 3479;
|
||||||
|
minPort = 49160;
|
||||||
|
maxPort = 49200;
|
||||||
|
};
|
||||||
netbird = {
|
netbird = {
|
||||||
enable = true;
|
enable = true;
|
||||||
targetName = "netbird";
|
targetName = "netbird";
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ in
|
|||||||
OIDC_AUTH_LOGOUT=true
|
OIDC_AUTH_LOGOUT=true
|
||||||
SESSION_SECRET=${config.sops.placeholder."mirotalk/session_secret"}
|
SESSION_SECRET=${config.sops.placeholder."mirotalk/session_secret"}
|
||||||
|
|
||||||
HOST_PROTECTED=true
|
HOST_PROTECTED=false
|
||||||
HOST_USER_AUTH=false
|
HOST_USER_AUTH=false
|
||||||
HOST_USERS='[]'
|
HOST_USERS='[]'
|
||||||
|
|
||||||
@@ -35,8 +35,12 @@ in
|
|||||||
|
|
||||||
STUN_SERVER_ENABLED=true
|
STUN_SERVER_ENABLED=true
|
||||||
STUN_SERVER_URL=${stunUrl}
|
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
|
STATS_ENABLED=false
|
||||||
SURVEY_ENABLED=false
|
SURVEY_ENABLED=false
|
||||||
'';
|
'';
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ in
|
|||||||
|
|
||||||
config = mkIf rootCfg.enable {
|
config = mkIf rootCfg.enable {
|
||||||
virtualisation.oci-containers.containers."${cfg.name}" = {
|
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"; # 1.9.39 (2026-09-03)
|
||||||
image = "docker.io/mirotalk/p2p@sha256:c05675e2e3e8a2bb1ee63f07dcaaf8523a30b4dee4d1e594594ff5e36c959b07";
|
|
||||||
ports = [
|
ports = [
|
||||||
"0.0.0.0:${toString cfg.hostHttpPort}:3000"
|
"0.0.0.0:${toString cfg.hostHttpPort}:3000"
|
||||||
];
|
];
|
||||||
@@ -44,6 +43,9 @@ in
|
|||||||
};
|
};
|
||||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||||
partOf = [ "${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" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ config, ... }:
|
{ config, lib, ... }:
|
||||||
{
|
{
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "homelab";
|
hostName = "homelab";
|
||||||
@@ -17,6 +17,16 @@
|
|||||||
allowedUDPPorts = [
|
allowedUDPPorts = [
|
||||||
3478
|
3478
|
||||||
7359
|
7359
|
||||||
|
51820
|
||||||
|
]
|
||||||
|
++ lib.optionals config.selfhosted.turn.enable [
|
||||||
|
config.selfhosted.turn.listenPort
|
||||||
|
];
|
||||||
|
allowedUDPPortRanges = lib.optionals config.selfhosted.turn.enable [
|
||||||
|
{
|
||||||
|
from = config.selfhosted.turn.minPort;
|
||||||
|
to = config.selfhosted.turn.maxPort;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user