From 1ef033c754069454e28740f5f2842a7c897a2d88 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Tue, 28 Nov 2023 05:43:23 +0100 Subject: [PATCH] bekkalokk/ingress: proxy matrix well-known files to bicep --- hosts/bekkalokk/services/nginx/ingress.nix | 10 ++++++++++ hosts/bicep/services/matrix/synapse.nix | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hosts/bekkalokk/services/nginx/ingress.nix b/hosts/bekkalokk/services/nginx/ingress.nix index 55da4a0..2950846 100644 --- a/hosts/bekkalokk/services/nginx/ingress.nix +++ b/hosts/bekkalokk/services/nginx/ingress.nix @@ -38,6 +38,16 @@ # Redirect everything else to the main website "/".return = "301 https://www.pvv.ntnu.no$request_uri"; + + # Proxy the matrix well-known files + # Host has be set before proxy_pass + # The header must be set so nginx on the other side routes it to the right place + "/.well-known/matrix/" = { + extraConfig = '' + proxy_set_header Host matrix.pvv.ntnu.no; + proxy_pass https://matrix.pvv.ntnu.no/.well-known/matrix/; + ''; + }; }; }; }; diff --git a/hosts/bicep/services/matrix/synapse.nix b/hosts/bicep/services/matrix/synapse.nix index 1341dec..2b0d160 100644 --- a/hosts/bicep/services/matrix/synapse.nix +++ b/hosts/bicep/services/matrix/synapse.nix @@ -216,7 +216,19 @@ in { services.redis.servers."".enable = true; - services.nginx.virtualHosts."matrix.pvv.ntnu.no" = lib.mkMerge [({ + services.nginx.virtualHosts."matrix.pvv.ntnu.no" = lib.mkMerge [ + ({ + locations."/.well-known/matrix/server" = { + return = '' + 200 '{"m.server": "matrix.pvv.ntnu.no:443"}' + ''; + extraConfig = '' + default_type application/json; + add_header Access-Control-Allow-Origin *; + ''; + }; + }) + ({ locations = let connectionInfo = w: matrix-lib.workerConnectionResource "metrics" w; socketAddress = w: let c = connectionInfo w; in "${c.host}:${toString (c.port)}";