From a2925e83ae26bf766747068535a07a004d81a3a1 Mon Sep 17 00:00:00 2001 From: Malte Brandy Date: Thu, 10 Dec 2020 00:28:08 +0100 Subject: [PATCH] Improve synapse config --- nixos/roles/matrix-synapse.nix | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/nixos/roles/matrix-synapse.nix b/nixos/roles/matrix-synapse.nix index 7514584b..19a66e90 100644 --- a/nixos/roles/matrix-synapse.nix +++ b/nixos/roles/matrix-synapse.nix @@ -10,26 +10,27 @@ in { enableACME = true; forceSSL = true; locations = { - "/.well-known/matrix/server".extraConfig = '' - default_type application/json; - return 200 "{\"m.server\": \"matrix.maralorn.de:443\"}"; - ''; - "/.well-known/matrix/client".extraConfig = '' - default_type application/json; - return 200 "{\"m.homeserver\": { \"base_url\":\"https://matrix.maralorn.de\"} }"; - ''; + "/.well-known/matrix/server".extraConfig = + let server."m.server" = "${hostName}:443"; + in '' + add_header Content-Type application/json; + return 200 '${builtins.toJSON server}'; + ''; + "/.well-known/matrix/client".extraConfig = + let client."m.homeserver" = { "base_url" = "https://${hostName}"; }; + in '' + add_header Content-Type application/json; + add_header Access-Control-Allow-Origin *; + return 200 '${builtins.toJSON client}'; + ''; }; - extraConfig = - "\n add_header 'Access-Control-Allow-Origin' '*';\n add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';\n add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization';\n "; }; virtualHosts."${hostName}" = { forceSSL = true; enableACME = true; - locations = { - "/" = { - proxyPass = "http://[::1]:8008"; - extraConfig = "proxy_set_header X-Forwarded-For $remote_addr;"; - }; + locations."/" = { + proxyPass = "http://[::1]:8008"; + extraConfig = "proxy_set_header X-Forwarded-For $remote_addr;"; }; }; };