Skip to content

Commit

Permalink
synapse: fix federated media
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed Sep 14, 2024
1 parent 98c1a81 commit 8737a99
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions nixos/modules/services/matrix/synapse/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}" = {
Expand Down

0 comments on commit 8737a99

Please sign in to comment.