From af1ac44440c3918910cf378a4ead96a94a3f6bd6 Mon Sep 17 00:00:00 2001 From: happysalada Date: Mon, 18 Oct 2021 19:08:46 +0900 Subject: [PATCH] jitsi: add caddy reverse proxy option --- .../modules/services/web-apps/jitsi-meet.nix | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/nixos/modules/services/web-apps/jitsi-meet.nix b/nixos/modules/services/web-apps/jitsi-meet.nix index e4f31c3a9395..2eacd87ae6fd 100644 --- a/nixos/modules/services/web-apps/jitsi-meet.nix +++ b/nixos/modules/services/web-apps/jitsi-meet.nix @@ -144,6 +144,8 @@ in ''; }; + caddy.enable = mkEnableOption "Whether to enablle caddy reverse proxy to expose jitsi-meet"; + prosody.enable = mkOption { type = bool; default = true; @@ -322,6 +324,42 @@ in }; }; + services.caddy = mkIf cfg.caddy.enable { + enable = mkDefault true; + virtualHosts.${cfg.hostName} = { + extraConfig = + let + templatedJitsiMeet = pkgs.runCommand "templated-jitsi-meet" {} '' + cp -R ${pkgs.jitsi-meet}/* . + for file in *.html **/*.html ; do + ${pkgs.sd}/bin/sd '' '{{ include "$1" }}' $file + done + rm config.js + rm interface_config.js + cp -R . $out + cp ${overrideJs "${pkgs.jitsi-meet}/config.js" "config" (recursiveUpdate defaultCfg cfg.config) cfg.extraConfig} $out/config.js + cp ${overrideJs "${pkgs.jitsi-meet}/interface_config.js" "interfaceConfig" cfg.interfaceConfig ""} $out/interface_config.js + cp ./libs/external_api.min.js $out/external_api.js + ''; + in '' + handle /http-bind { + header Host ${cfg.hostName} + reverse_proxy 127.0.0.1:5280 + } + handle /xmpp-websocket { + reverse_proxy 127.0.0.1:5280 + } + handle { + templates + root * ${templatedJitsiMeet} + try_files {path} {path} + try_files {path} /index.html + file_server + } + ''; + }; + }; + services.jitsi-videobridge = mkIf cfg.videobridge.enable { enable = true; xmppConfigs."localhost" = {