From 0d40ca116641cf6567a1fd323c5e636ee6c9e4f9 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Sat, 14 Sep 2024 10:06:53 -0600 Subject: [PATCH] wip Signed-off-by: Sumner Evans --- .../services/matrix/synapse/default.nix | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/matrix/synapse/default.nix b/nixos/modules/services/matrix/synapse/default.nix index b3a5295..214eeb7 100644 --- a/nixos/modules/services/matrix/synapse/default.nix +++ b/nixos/modules/services/matrix/synapse/default.nix @@ -352,7 +352,15 @@ in { # Set up nginx to forward requests properly. services.nginx = { enable = true; - virtualHosts = { + virtualHosts = let + mediaRepoLocation = { + priority = 0; # media repo needs to be before federation + proxyPass = "http://0.0.0.0:8011"; # without a trailing / + extraConfig = '' + access_log /var/log/nginx/matrix-media-repo.access.log; + ''; + }; + in { # Reverse proxy for Matrix client-server and server-server communication "matrix.${config.networking.domain}" = { enableACME = true; @@ -379,16 +387,13 @@ in { access_log /var/log/nginx/matrix-synchotron.access.log; ''; }; - locations."~ ^/(_matrix/media/.*/upload|_matrix/client/v1/media|_matrix/federation/v1/media|_synapse/admin/v1/(purge_media_cache|(room|user)/.*/media.*|media/.*|quarantine_media/.*|users/.*/media))" = - { - proxyPass = "http://0.0.0.0:8011"; # without a trailing / - extraConfig = '' - access_log /var/log/nginx/matrix-media-repo.access.log; - ''; - }; - - # black-hole old media - locations."~ ^/_matrix/media/.*/download" = { return = "404"; }; + + # Media locations + locations."~ ^/_matrix/media/" = mediaRepoLocation; + locations."~ ^/_matrix/client/.*/media/" = mediaRepoLocation; + locations."~ ^/_matrix/federation/.*/media/" = mediaRepoLocation; + locations."~ ^/_synapse/admin/v1/(purge_media_cache|(room|user)/.*/media.*|media/.*|quarantine_media/.*|users/.*/media)" = + mediaRepoLocation; }; "syncv3.${config.networking.domain}" = {