nixos/peertube: update nginx configuration

Izorkin 32673128 1915c85b

Changed files
+79 -17
nixos
modules
services
web-apps
+79 -17
nixos/modules/services/web-apps/peertube.nix
···
'';
};
+
locations."~ ^/plugins/[^/]+(/[^/]+)?/ws/" = {
+
tryFiles = "/dev/null @api_websocket";
+
priority = 1230;
+
};
+
locations."@api_websocket" = {
proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}";
-
priority = 1230;
+
priority = 1240;
extraConfig = ''
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
···
'';
};
-
locations."~ ^/lazy-static/(avatars|banners)/" = {
+
locations."^~ /lazy-static/avatars/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.avatars;
priority = 1330;
···
add_header Cache-Control 'public, max-age=7200';
rewrite ^/lazy-static/avatars/(.*)$ /$1 break;
+
'';
+
};
+
+
locations."^~ /lazy-static/banners/" = {
+
tryFiles = "$uri @api";
+
root = cfg.settings.storage.avatars;
+
priority = 1340;
+
extraConfig = ''
+
if ($request_method = 'OPTIONS') {
+
${nginxCommonHeaders}
+
add_header Access-Control-Max-Age 1728000;
+
add_header Cache-Control 'no-cache';
+
add_header Content-Type 'text/plain charset=UTF-8';
+
add_header Content-Length 0;
+
return 204;
+
}
+
+
${nginxCommonHeaders}
+
add_header Cache-Control 'public, max-age=7200';
+
rewrite ^/lazy-static/banners/(.*)$ /$1 break;
'';
};
···
locations."^~ /lazy-static/previews/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.previews;
-
priority = 1340;
+
priority = 1350;
extraConfig = ''
if ($request_method = 'OPTIONS') {
${nginxCommonHeaders}
···
'';
};
+
locations."^~ /static/streaming-playlists/private/" = {
+
proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}";
+
priority = 1410;
+
extraConfig = ''
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
proxy_set_header Host $host;
+
proxy_set_header X-Real-IP $remote_addr;
+
+
proxy_limit_rate 5M;
+
'';
+
};
+
+
locations."^~ /static/webseed/private/" = {
+
proxyPass = "http://127.0.0.1:${toString cfg.listenHttp}";
+
priority = 1420;
+
extraConfig = ''
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
proxy_set_header Host $host;
+
proxy_set_header X-Real-IP $remote_addr;
+
+
proxy_limit_rate 5M;
+
'';
+
};
+
locations."^~ /static/thumbnails/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.thumbnails;
-
priority = 1350;
+
priority = 1430;
extraConfig = ''
if ($request_method = 'OPTIONS') {
${nginxCommonHeaders}
···
locations."^~ /static/redundancy/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.redundancy;
-
priority = 1360;
+
priority = 1440;
extraConfig = ''
+
set $peertube_limit_rate 800k;
+
+
if ($request_uri ~ -fragmented.mp4$) {
+
set $peertube_limit_rate 5M;
+
}
+
if ($request_method = 'OPTIONS') {
${nginxCommonHeaders}
add_header Access-Control-Max-Age 1728000;
···
access_log off;
}
+
aio threads;
sendfile on;
sendfile_max_chunk 1M;
+
limit_rate $peertube_limit_rate;
limit_rate_after 5M;
-
-
set $peertube_limit_rate 800k;
-
set $limit_rate $peertube_limit_rate;
rewrite ^/static/redundancy/(.*)$ /$1 break;
'';
···
locations."^~ /static/streaming-playlists/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.streaming_playlists;
-
priority = 1370;
+
priority = 1450;
extraConfig = ''
+
set $peertube_limit_rate 800k;
+
+
if ($request_uri ~ -fragmented.mp4$) {
+
set $peertube_limit_rate 5M;
+
}
+
if ($request_method = 'OPTIONS') {
${nginxCommonHeaders}
add_header Access-Control-Max-Age 1728000;
···
sendfile on;
sendfile_max_chunk 1M;
+
limit_rate $peertube_limit_rate;
limit_rate_after 5M;
-
-
set $peertube_limit_rate 5M;
-
set $limit_rate $peertube_limit_rate;
rewrite ^/static/streaming-playlists/(.*)$ /$1 break;
'';
};
-
locations."~ ^/static/webseed/" = {
+
locations."^~ /static/webseed/" = {
tryFiles = "$uri @api";
root = cfg.settings.storage.videos;
-
priority = 1380;
+
priority = 1460;
extraConfig = ''
+
set $peertube_limit_rate 800k;
+
+
if ($request_uri ~ -fragmented.mp4$) {
+
set $peertube_limit_rate 5M;
+
}
+
if ($request_method = 'OPTIONS') {
${nginxCommonHeaders}
add_header Access-Control-Max-Age 1728000;
···
sendfile on;
sendfile_max_chunk 1M;
+
limit_rate $peertube_limit_rate;
limit_rate_after 5M;
-
-
set $peertube_limit_rate 800k;
-
set $limit_rate $peertube_limit_rate;
rewrite ^/static/webseed/(.*)$ /$1 break;
'';