forked from nutomic/peertube.social
Serve video files directly from disk
This commit is contained in:
parent
7ddae2c89f
commit
53c23727e7
2 changed files with 41 additions and 9 deletions
|
@ -27,6 +27,7 @@ services:
|
||||||
image: nginx:1.15-alpine
|
image: nginx:1.15-alpine
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf
|
- ./nginx.conf:/etc/nginx/nginx.conf
|
||||||
|
- ./volumes-large:/data-external:ro
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.frontend.rule=Host:${PEERTUBE_WEBSERVER_HOSTNAME}
|
- traefik.frontend.rule=Host:${PEERTUBE_WEBSERVER_HOSTNAME}
|
||||||
|
|
|
@ -47,17 +47,48 @@ http {
|
||||||
add_header X-Cached $upstream_cache_status;
|
add_header X-Cached $upstream_cache_status;
|
||||||
}
|
}
|
||||||
location ~ ^/static/(webseed|redundancy)/ {
|
location ~ ^/static/(webseed|redundancy)/ {
|
||||||
slice 1m;
|
# NOTE: Its not possible to use proxy_cache for files that are served from disk without complicated workarounds
|
||||||
proxy_cache peertube_cache;
|
# Anyway caching is not a great idea because files are changed on disk after transcoding.
|
||||||
proxy_cache_valid 206 1h;
|
#slice 1m;
|
||||||
proxy_cache_key $uri$is_args$args$slice_range;
|
#proxy_cache peertube_cache;
|
||||||
proxy_set_header Range $slice_range;
|
#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
|
# for debugging
|
||||||
#add_header X-Cache-Status $upstream_cache_status;
|
#add_header X-Cache-Status $upstream_cache_status;
|
||||||
proxy_http_version 1.1;
|
|
||||||
# required workaround for https://github.com/Chocobozzz/PeerTube/issues/1777
|
# Clients usually have 4 simultaneous webseed connections, so the real limit is 3MB/s per client
|
||||||
proxy_ignore_headers Cache-Control;
|
limit_rate 800k;
|
||||||
proxy_pass http://peertube:9000;
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
try_files $uri /;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue