From ae2de6339f7511e0e1f590bc44e5e9e0c0afb651 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 19 Apr 2019 02:57:19 +0200 Subject: [PATCH] Enable caching for videos --- inventory | 2 +- templates/env | 2 +- templates/nginx.conf | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/inventory b/inventory index d276bad..7f91850 100644 --- a/inventory +++ b/inventory @@ -1,6 +1,6 @@ [peertube] root@testing.peertube.social domain=testing.peertube.social -felix@peertube.social domain=peertube.social +#felix@peertube.social domain=peertube.social [all:vars] ansible_connection=ssh diff --git a/templates/env b/templates/env index b5592da..ff1469e 100644 --- a/templates/env +++ b/templates/env @@ -8,5 +8,5 @@ PEERTUBE_SMTP_FROM=info@{{ domain }} PEERTUBE_SMTP_TLS=false PEERTUBE_ADMIN_EMAIL=info@{{ domain }} -POSTGRES_USER=postgres +POSTGRES_USER=peertube POSTGRES_PASSWORD={{ postgres_password }} diff --git a/templates/nginx.conf b/templates/nginx.conf index 61e3e68..36d98ab 100644 --- a/templates/nginx.conf +++ b/templates/nginx.conf @@ -3,7 +3,7 @@ events { } http { - proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=peertube_cache:10m max_size=15g inactive=7d use_temp_path=off; + proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=peertube_cache:10m max_size=15g use_temp_path=off; server { listen 9000; @@ -46,5 +46,18 @@ http { proxy_cache_lock on; add_header X-Cached $upstream_cache_status; } + location ~ ^/static/(webseed|redundancy)/ { + slice 1m; + proxy_cache peertube_cache; + proxy_cache_valid 206 1h; + proxy_cache_key $uri$is_args$args$slice_range; + proxy_set_header Range $slice_range; + # for debugging + #add_header X-Cache-Status $upstream_cache_status; + proxy_http_version 1.1; + # required workaround for https://github.com/Chocobozzz/PeerTube/issues/1777 + proxy_ignore_headers Cache-Control; + proxy_pass http://peertube:9000; + } } }