From dcfd03a94f35d8949c8d8e3476f8b830e01d8b71 Mon Sep 17 00:00:00 2001 From: SchweGELBin Date: Tue, 16 Sep 2025 19:00:30 +0200 Subject: [PATCH] nixos/peertube: update nginx configuration Co-authored-by: Izorkin --- nixos/modules/services/web-apps/peertube.nix | 67 ++++++-------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/nixos/modules/services/web-apps/peertube.nix b/nixos/modules/services/web-apps/peertube.nix index 8e237ae90a36..795d0947ea9e 100644 --- a/nixos/modules/services/web-apps/peertube.nix +++ b/nixos/modules/services/web-apps/peertube.nix @@ -639,7 +639,6 @@ in locations."~ ^/api/v1/videos/(upload|([^/]+/studio/edit))$" = { tryFiles = "/dev/null @api"; - root = cfg.settings.storage.tmp; priority = 1140; extraConfig = '' @@ -647,18 +646,18 @@ in client_max_body_size 12G; add_header X-File-Maximum-Size 8G always; + proxy_request_buffering off; '' + nginxCommonHeaders; }; locations."~ ^/api/v1/runners/jobs/[^/]+/(update|success)$" = { tryFiles = "/dev/null @api"; - root = cfg.settings.storage.tmp; priority = 1150; extraConfig = '' - client_max_body_size 12G; - add_header X-File-Maximum-Size 8G always; + client_max_body_size 0; + proxy_request_buffering off; '' + nginxCommonHeaders; }; @@ -668,8 +667,8 @@ in priority = 1160; extraConfig = '' - client_max_body_size 6M; - add_header X-File-Maximum-Size 4M always; + client_max_body_size 12M; + add_header X-File-Maximum-Size 8M always; '' + nginxCommonHeaders; }; @@ -731,14 +730,6 @@ in }; # Bypass PeerTube for performance reasons. - locations."~ ^/client/(assets/images/(icons/icon-36x36\\.png|icons/icon-48x48\\.png|icons/icon-72x72\\.png|icons/icon-96x96\\.png|icons/icon-144x144\\.png|icons/icon-192x192\\.png|icons/icon-512x512\\.png|logo\\.svg|favicon\\.png|default-playlist\\.jpg|default-avatar-account\\.png|default-avatar-account-48x48\\.png|default-avatar-video-channel\\.png|default-avatar-video-channel-48x48\\.png))$" = - { - tryFiles = "/client-overrides/$1 /client/$1 $1"; - priority = 1310; - - extraConfig = nginxCommonHeaders; - }; - locations."~ ^/client/(.*\\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$" = { alias = "${cfg.package}/client/dist/$1"; priority = 1320; @@ -748,6 +739,14 @@ in + nginxCommonHeaders; }; + locations."~ ^/client/(assets/images/(default-playlist\\.jpg|default-avatar-account\\.png|default-avatar-account-48x48\\.png|default-avatar-video-channel\\.png|default-avatar-video-channel-48x48\\.png))$" = + { + tryFiles = "/client-overrides/$1 /client/$1 $1"; + priority = 1320; + + extraConfig = nginxCommonHeaders; + }; + locations."^~ /download/" = { proxyPass = "http://peertube"; priority = 1410; @@ -802,14 +801,10 @@ in locations."^~ /static/redundancy/" = { tryFiles = "$uri @api"; - root = cfg.settings.storage.redundancy; + alias = cfg.settings.storage.redundancy; priority = 1450; extraConfig = '' - set $peertube_limit_rate 800k; - - if ($request_uri ~ -fragmented.mp4$) { - set $peertube_limit_rate 5M; - } + set $peertube_limit_rate 5M; if ($request_method = 'OPTIONS') { ${nginxCommonHeaders} @@ -830,21 +825,15 @@ in limit_rate $peertube_limit_rate; limit_rate_after 5M; - - rewrite ^/static/redundancy/(.*)$ /$1 break; ''; }; locations."^~ /static/streaming-playlists/" = { tryFiles = "$uri @api"; - root = cfg.settings.storage.streaming_playlists; + alias = cfg.settings.storage.streaming_playlists; priority = 1460; extraConfig = '' - set $peertube_limit_rate 800k; - - if ($request_uri ~ -fragmented.mp4$) { - set $peertube_limit_rate 5M; - } + set $peertube_limit_rate 5M; if ($request_method = 'OPTIONS') { ${nginxCommonHeaders} @@ -865,21 +854,15 @@ in limit_rate $peertube_limit_rate; limit_rate_after 5M; - - rewrite ^/static/streaming-playlists/(.*)$ /$1 break; ''; }; locations."^~ /static/web-videos/" = { tryFiles = "$uri @api"; - root = cfg.settings.storage.web_videos; + alias = cfg.settings.storage.web_videos; priority = 1470; extraConfig = '' - set $peertube_limit_rate 800k; - - if ($request_uri ~ -fragmented.mp4$) { - set $peertube_limit_rate 5M; - } + set $peertube_limit_rate 5M; if ($request_method = 'OPTIONS') { ${nginxCommonHeaders} @@ -900,21 +883,15 @@ in limit_rate $peertube_limit_rate; limit_rate_after 5M; - - rewrite ^/static/web-videos/(.*)$ /$1 break; ''; }; locations."^~ /static/webseed/" = { tryFiles = "$uri @api"; - root = cfg.settings.storage.web_videos; + alias = cfg.settings.storage.web_videos; priority = 1480; extraConfig = '' - set $peertube_limit_rate 800k; - - if ($request_uri ~ -fragmented.mp4$) { - set $peertube_limit_rate 5M; - } + set $peertube_limit_rate 5M; if ($request_method = 'OPTIONS') { ${nginxCommonHeaders} @@ -935,8 +912,6 @@ in limit_rate $peertube_limit_rate; limit_rate_after 5M; - - rewrite ^/static/webseed/(.*)$ /web-videos/$1 break; ''; }; };