diff --git a/modules/media-proxy.nix b/modules/media-proxy.nix index bc653f8..cf12f17 100644 --- a/modules/media-proxy.nix +++ b/modules/media-proxy.nix @@ -1,6 +1,5 @@ { config, lib, pkgs, ... }: let - port = 8888; services = { "media" = config.sops.secrets.media-proxy-auth.path; "media-sb" = config.sops.secrets.media-proxy-auth.path; @@ -24,37 +23,27 @@ in enable = true; commonHttpConfig = '' map $http_referer $media_proxy_referer { - ~^http://localhost:8888/ ""; + ~^http://.*\.localhost/ ""; default $http_referer; } ''; - virtualHosts.media-proxy = { - serverName = "localhost"; - listen = [ - { inherit port; addr = "127.0.0.1"; } - { inherit port; addr = "[::1]"; } - ]; - locations = { - "/".extraConfig = '' - rewrite ^/__nginx-interactive-index-assets__/(.*)$ /media/__nginx-interactive-index-assets__/$1; - ''; - } // lib.mapAttrs' - (name: secret: { - name = "/${name}/"; - value = { - proxyPass = "https://${name}.sbruder.de/"; - proxyWebsockets = true; - extraConfig = '' - proxy_buffering off; - include ${secret}; - charset utf-8; - proxy_set_header Referer $media_proxy_referer; - proxy_set_header Origin $media_proxy_referer; - ''; - }; - }) - services; - }; + virtualHosts = lib.mapAttrs' + (name: secret: lib.nameValuePair "${name}.localhost" { + locations."/" = { + proxyPass = "https://${name}.sbruder.de/"; + proxyWebsockets = true; + # they interfere here, as the host needs to be changed + recommendedProxySettings = false; + extraConfig = '' + proxy_buffering off; + include ${secret}; + charset utf-8; + proxy_set_header Referer $media_proxy_referer; + proxy_set_header Origin $media_proxy_referer; + ''; + }; + }) + services; }; }; }