Compare commits

...

5 commits

3 changed files with 14 additions and 64 deletions

View file

@ -17,6 +17,8 @@ services:
peertube:
image: chocobozzz/peertube:{{ peertube_version }}-buster
ports:
- "1935:1935"
env_file:
- .env
volumes:

View file

@ -15,9 +15,6 @@ http {
}
}
proxy_cache_path /var/cache/peertube_frontend levels=1:2 keys_zone=peertube_frontend_cache:10m max_size=100m use_temp_path=off;
proxy_cache_path /var/cache/peertube_video levels=1:2 keys_zone=peertube_video_cache:10m max_size={{ cache_size_gb }}g use_temp_path=off;
geo $bad_user {
default 0;
103.114.191.0/24 1;
@ -82,69 +79,11 @@ ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECD
proxy_read_timeout 600;
send_timeout 600;
# https://www.nginx.com/blog/nginx-caching-guide/
proxy_cache peertube_frontend_cache;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache_revalidate on;
proxy_cache_lock on;
proxy_cache_min_uses 5;
#add_header X-Cached $upstream_cache_status;
location ~ ^/client/(.*\.(js|css|woff2|otf|ttf|woff|eot))$ {
proxy_pass http://peertube:9000;
add_header Cache-Control "public, max-age=31536000, immutable";
}
}
location ~ ^/static/(webseed|redundancy|streaming-playlists)/ {
# NOTE: Its not possible to use proxy_cache for files that are served from disk without complicated workarounds
# Anyway caching is not a great idea because files are changed on disk after transcoding.
#slice 1m;
#proxy_cache peertube_video_cache;
#proxy_cache_valid 206 1h;
#proxy_cache_key $uri$is_args$args$slice_range;
#proxy_set_header Range $slice_range;
#proxy_http_version 1.1;
#proxy_pass http://peertube:9000;
# required workaround for https://github.com/Chocobozzz/PeerTube/issues/1777
#proxy_ignore_headers Cache-Control;
# for debugging
#add_header X-Cache-Status $upstream_cache_status;
# Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
set $peertube_limit_rate 800k;
# Increase rate limit in HLS mode, because we don't have multiple simultaneous connections
if ($request_uri ~ -fragmented.mp4$) {
set $peertube_limit_rate 5000k;
}
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;
}
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';
# Don't spam access log file with byte range requests
access_log off;
}
root /data-external;
rewrite ^/static/webseed/(.*)$ /videos/$1 break;
rewrite ^/static/redundancy/(.*)$ /redundancy/$1 break;
rewrite ^/static/streaming-playlists/(.*)$ /streaming-playlists/$1 break;
try_files $uri /;
}
# Websocket tracker
location /tracker/socket {
# Peers send a message to the tracker every 15 minutes

View file

@ -74,7 +74,16 @@ trending:
videos:
interval_days: 7 # Compute trending videos for the last x days
views:
videos:
# PeerTube creates a database entry every hour for each video to track views over a period of time
# This is used in particular by the Trending page
# PeerTube could remove old remote video views if you want to reduce your database size (video view counter will not be altered)
# -1 means no cleanup
# Other values could be '6 months' or '30 days' etc (PeerTube will periodically delete old entries from database)
remote:
max_age: '30 days'
csp:
enabled: true
report_only: true
federation:
videos:
federate_unlisted: false