cluster

Infrastructure files for Nordgedanken and Midnightthoughts.
git clone git://archive.git.mtrnord.blog/MTRNord/cluster.git
Log | Files | Refs | README

commit 41f1de8b78ee662661ea9e63b4f0e9919ce4bd22
parent eef543cf8213167ad08216f16130edc88eb4e678
Author: MTRNord <MTRNord@users.noreply.github.com>
Date:   Sun,  1 Feb 2026 21:11:54 +0100

try to fix s3

Signed-off-by: MTRNord <MTRNord@users.noreply.github.com>

Diffstat:
Mapps/talos_cluster/peertube/nginx/peertube.conf | 96++++++++++++++++++++++++++++++++++++-------------------------------------------
1 file changed, 44 insertions(+), 52 deletions(-)

diff --git a/apps/talos_cluster/peertube/nginx/peertube.conf b/apps/talos_cluster/peertube/nginx/peertube.conf @@ -1,7 +1,7 @@ -# PeerTube nginx configuration with S3 caching for Hetzner Object Storage -# Based on official PeerTube S3 cache configuration +# PeerTube nginx configuration with S3 caching +# Based on upstream PeerTube S3 proxy documentation +# Adapted for sidecar deployment proxying both PeerTube and S3 -# Cache paths for S3 content proxy_cache_path /var/cache/nginx/s3 levels=1:2 keys_zone=CACHE-S3:100m inactive=48h max_size=10G; proxy_cache_path /var/cache/nginx/s3-ts levels=1:2 keys_zone=CACHE-S3-TS:10m inactive=60s max_size=1G; @@ -34,6 +34,10 @@ server { gzip_buffers 16 8k; gzip_comp_level 2; + # S3 backend configuration (environment variables substituted by nginx) + set $s3_backend '${S3_ENDPOINT}'; + set $s3_host '${S3_HOST}'; + ## # PeerTube API and Application ## @@ -122,22 +126,16 @@ server { } ## - # S3 Cache Proxy - Main media files - # Configured for Hetzner Object Storage + # S3 Cache Proxy - Named locations ## - set $s3_backend '${S3_ENDPOINT}'; - set $s3_host '${S3_HOST}'; - # Cache S3 files for a long time (filenames change when content updates) location @s3 { limit_except GET OPTIONS { deny all; } - resolver 1.1.1.1 8.8.8.8 valid=300s; - resolver_timeout 10s; - + resolver 1.1.1.1 8.8.8.8; proxy_set_header Host $s3_host; proxy_set_header Connection ''; proxy_set_header Authorization ''; @@ -153,7 +151,7 @@ server { proxy_hide_header x-amz-bucket-region; proxy_hide_header x-amzn-requestid; proxy_ignore_headers Set-Cookie; - proxy_pass $s3_backend$uri; + proxy_pass $s3_backend$s3_uri; proxy_intercept_errors off; proxy_cache CACHE-S3; @@ -179,9 +177,7 @@ server { deny all; } - resolver 1.1.1.1 8.8.8.8 valid=300s; - resolver_timeout 10s; - + resolver 1.1.1.1 8.8.8.8; proxy_set_header Host $s3_host; proxy_set_header Connection ''; proxy_set_header Authorization ''; @@ -197,7 +193,7 @@ server { proxy_hide_header x-amz-bucket-region; proxy_hide_header x-amzn-requestid; proxy_ignore_headers Set-Cookie; - proxy_pass $s3_backend$uri; + proxy_pass $s3_backend$s3_uri; proxy_intercept_errors off; proxy_cache CACHE-S3-TS; @@ -223,9 +219,7 @@ server { deny all; } - resolver 1.1.1.1 8.8.8.8 valid=300s; - resolver_timeout 10s; - + resolver 1.1.1.1 8.8.8.8; proxy_set_header Host $s3_host; proxy_set_header Connection ''; proxy_set_header Authorization ''; @@ -241,7 +235,7 @@ server { proxy_hide_header x-amz-bucket-region; proxy_hide_header x-amzn-requestid; proxy_ignore_headers Set-Cookie; - proxy_pass $s3_backend$uri; + proxy_pass $s3_backend$s3_uri; proxy_intercept_errors off; expires 0; @@ -268,44 +262,42 @@ server { proxy_pass http://peertube_backend; } - # Public static content - route to S3 cache - location ~ ^/static/(webseed|web-videos|redundancy|streaming-playlists)/ { - limit_rate_after 5M; - set $peertube_limit_rate 5M; - limit_rate $peertube_limit_rate; - - if ($request_method = 'OPTIONS') { - add_header Access-Control-Allow-Origin '*'; - add_header Access-Control-Allow-Methods 'GET, OPTIONS'; - add_header Access-Control-Allow-Headers 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; - add_header Access-Control-Max-Age 1728000; - add_header Content-Type 'text/plain charset=UTF-8'; - add_header Content-Length 0; - return 204; + # M3U8 and JSON files - no cache (for live streaming) + location ~ ^/static/.*\.(json|m3u8)$ { + # Strip /static/ prefix for S3 path + set $s3_uri $uri; + if ($uri ~ ^/static/(.*)$) { + set $s3_uri /$1; } + try_files /dev/null @s3_nocache; + } - if ($request_method = 'GET') { - add_header Access-Control-Allow-Origin '*'; - add_header Access-Control-Allow-Methods 'GET, OPTIONS'; - add_header Access-Control-Allow-Headers 'Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + # .ts files for live streaming - short cache + location ~ ^/static/.*\.ts$ { + # Strip /static/ prefix for S3 path + set $s3_uri $uri; + if ($uri ~ ^/static/(.*)$) { + set $s3_uri /$1; } - - # Rewrite paths for S3 - rewrite ^/static/webseed/(.*)$ /web-videos/$1 break; - rewrite ^/static/(.*)$ /$1 break; - - try_files $uri @s3; + try_files /dev/null @s3-ts; } - # .ts files for live streaming - location ~ ^/static/.*\.ts$ { - rewrite ^/static/(.*)$ /$1 break; - try_files $uri @s3-ts; + # Public static content - route to S3 cache with long cache + location ~ ^/static/webseed/ { + # Map old webseed path to web-videos + set $s3_uri $uri; + if ($uri ~ ^/static/webseed/(.*)$) { + set $s3_uri /web-videos/$1; + } + try_files /dev/null @s3; } - # M3U8 and JSON files - no cache - location ~ ^/static/.*\.(json|m3u8)$ { - rewrite ^/static/(.*)$ /$1 break; - try_files $uri @s3_nocache; + location ~ ^/static/ { + # Strip /static/ prefix for S3 path + set $s3_uri $uri; + if ($uri ~ ^/static/(.*)$) { + set $s3_uri /$1; + } + try_files /dev/null @s3; } }