From c110570f008472958bd700d04f02fa3d1f9209fe Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Tue, 13 Aug 2024 03:23:15 -0600 Subject: sys/web/sites/matrix: enable sliding sync --- sys/web/sites/matrix.nix | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) (limited to 'sys/web/sites') diff --git a/sys/web/sites/matrix.nix b/sys/web/sites/matrix.nix index ee2f773..5583b47 100644 --- a/sys/web/sites/matrix.nix +++ b/sys/web/sites/matrix.nix @@ -20,35 +20,21 @@ in sites.portal.enable = true; }; - services.nginx.virtualHosts = { - ${domains.exdev.main}.locations = - let - serverConfig."m.server" = "${domains.matrix.main}:443"; - clientConfig."m.homeserver".base_url = "https://${domains.matrix.main}"; - - mkWellKnown = data: '' - default_type application/json; - add_header Access-Control-Allow-Origin *; - return 200 '${builtins.toJSON data}'; - ''; - in - { - "= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig; - "= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig; - }; - - ${domains.matrix.main} = { - forceSSL = true; - useACMEHost = domains.matrix.main; - - locations = - let - proxyLocation = - throwIf (hasSuffix "/" cfg.proxyUrl) - "matrix site: a trailing slash *must not* be used here" - cfg.proxyUrl; - in - { + services.nginx.virtualHosts = + let + proxyLocation = + throwIf (hasSuffix "/" cfg.proxyUrl) + "matrix site: a trailing slash *must not* be used here" + cfg.proxyUrl; + in + { + ${domains.exdev.main}.locations."/.well-known/matrix".proxyPass = proxyLocation; + + ${domains.matrix.main} = { + forceSSL = true; + useACMEHost = domains.matrix.main; + + locations = { "/".extraConfig = '' return 403; ''; @@ -60,7 +46,7 @@ in # Forward requests for e.g. SSO and password-resets. "/_synapse/client".proxyPass = proxyLocation; }; + }; }; - }; }; } -- cgit v1.2.3