From 0d5f97e1d94dca7ec58ddc1892eec4ec4640bd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Thu, 25 Aug 2022 19:39:03 +0100 Subject: [PATCH] forward logout to the media server --- config/services/matrix-media-repo.nix | 72 ++++++++++++++------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/config/services/matrix-media-repo.nix b/config/services/matrix-media-repo.nix index 523696fe..5f1e19b6 100644 --- a/config/services/matrix-media-repo.nix +++ b/config/services/matrix-media-repo.nix @@ -145,51 +145,55 @@ in { } ]; services.nginx.virtualHosts = let + mediaProxyConfig = { + proxyPass = "http://localhost:8008"; + proxyWebsockets = true; + extraConfig = '' + proxy_hide_header Access-Control-Allow-Origin; + add_header Access-Control-Allow-Origin '*' always; + ''; + }; main = { sslCertificate = "/var/lib/acme/chir.rs/cert.pem"; sslCertificateKey = "/var/lib/acme/chir.rs/key.pem"; - locations."/_matrix" = { - proxyPass = "https://matrix.int.chir.rs"; - proxyWebsockets = true; - extraConfig = '' - proxy_ssl_server_name on; - proxy_hide_header Access-Control-Allow-Origin; - add_header Access-Control-Allow-Origin '*' always; - ''; - }; - locations."/_matrix/media" = { - proxyPass = "http://localhost:8008"; - proxyWebsockets = true; - extraConfig = '' - proxy_hide_header Access-Control-Allow-Origin; - add_header Access-Control-Allow-Origin '*' always; - ''; - }; - locations."/.well-known/matrix/server" = { - extraConfig = '' - return 200 '{ "m.server": "matrix.chir.rs:443" }'; - ''; - }; - locations."/.well-known/matrix/client" = { - extraConfig = '' - add_header Access-Control-Allow-Origin '*'; - return 200 '{ "m.homeserver": { "base_url": "https://matrix.chir.rs" } }'; - ''; - }; - locations."/_synapse/metrics" = { - extraConfig = '' - return 404 'Not found'; - ''; + locations = { + "/_matrix" = { + proxyPass = "https://matrix.int.chir.rs"; + proxyWebsockets = true; + extraConfig = '' + proxy_ssl_server_name on; + proxy_hide_header Access-Control-Allow-Origin; + add_header Access-Control-Allow-Origin '*' always; + ''; + }; + "/_matrix/media" = mediaProxyConfig; + "/_matrix/client/v3/logout" = mediaProxyConfig; + locations."/.well-known/matrix/server" = { + extraConfig = '' + return 200 '{ "m.server": "matrix.chir.rs:443" }'; + ''; + }; + locations."/.well-known/matrix/client" = { + extraConfig = '' + add_header Access-Control-Allow-Origin '*'; + return 200 '{ "m.homeserver": { "base_url": "https://matrix.chir.rs" } }'; + ''; + }; + locations."/_synapse/metrics" = { + extraConfig = '' + return 404 'Not found'; + ''; + }; }; }; in { - "matrix.int.chir.rs" = main; - "matrix.chir.rs" = + "matrix.int.chir.rs" = main // { sslCertificate = "/var/lib/acme/int.chir.rs/cert.pem"; sslCertificateKey = "/var/lib/acme/int.chir.rs/key.pem"; }; + "matrix.chir.rs" = main; "chir.rs" = { locations."/.well-known/matrix/server" = { extraConfig = ''