diff --git a/conf/nginx.conf b/conf/nginx.conf index 5a13dec..af5d78f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,19 +19,19 @@ location @api { proxy_pass http://127.0.0.1:__PORT__; } -location = /api/v1/videos/upload-resumable { - client_max_body_size 0; - proxy_request_buffering off; - - try_files /dev/null @api; -} - location / { try_files /dev/null @api; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } +location ~ ^/api/v1/videos/(upload-resumable|([^/]+/source/replace-resumable))$ { + client_max_body_size 0; + proxy_request_buffering off; + + try_files /dev/null @api; +} + location ~ ^/api/v1/videos/(upload|([^/]+/studio/edit))$ { limit_except POST HEAD { deny all; } @@ -98,10 +98,9 @@ location ~ ^/plugins/[^/]+(/[^/]+)?/ws/ { root __DATA_DIR__/storage/; - # Enable compression for JS/CSS/HTML, for improved client load times. - # It might be nice to compress JSON/XML as returned by the API, but - # leaving that out to protect against potential BREACH attack. - +# Enable compression for JS/CSS/HTML, for improved client load times. +# It might be nice to compress JSON/XML as returned by the API, but +# leaving that out to protect against potential BREACH attack. # gzip on; gzip_vary on; gzip_types # text/html is always compressed by HttpGzipModule @@ -145,31 +144,7 @@ location ~ ^/client/(.*\.(js|css|png|svg|woff2|otf|ttf|woff|eot))$ { alias __INSTALL_DIR__/client/dist/$1; } -# Bypass PeerTube for performance reasons. Optional. -location ~ ^/static/(thumbnails|avatars)/ { - if ($request_method = 'OPTIONS') { - more_set_headers "Access-Control-Allow-Origin : *"; - more_set_headers "Access-Control-Allow-Methods : GET, OPTIONS"; - more_set_headers "Access-Control-Allow-Headers : Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type"; - more_set_headers "Access-Control-Max-Age : 1728000"; # Preflight request can be cached 20 days - more_set_headers "Content-Type : text/plain charset=UTF-8"; - more_set_headers "Content-Length : 0"; - return 204; - } - - more_set_headers "Access-Control-Allow-Origin : *"; - more_set_headers "Access-Control-Allow-Methods : GET, OPTIONS"; - more_set_headers "Access-Control-Allow-Headers : Range,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type"; - more_set_headers "Cache-Control : public, max-age=7200"; # Cache response 2 hours - - rewrite ^/static/(.*)$ /$1 break; - - root __DATA_DIR__/storage/; - - try_files $uri @api; -} - -location ~ ^(/static/(webseed|videos|streaming-playlists)/private/)|^/download { +location ~ ^(/static/(webseed|web-videos|streaming-playlists)/private/)|^/download { # We can't rate limit a try_files directive, so we need to duplicate @api proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -182,7 +157,7 @@ location ~ ^(/static/(webseed|videos|streaming-playlists)/private/)|^/download { } # Bypass PeerTube for performance reasons. Optional. -location ~ ^/static/(webseed|videos|redundancy|streaming-playlists)/ { +location ~ ^/static/(webseed|web-videos|redundancy|streaming-playlists)/ { limit_rate_after 5M; set $peertube_limit_rate 5M; @@ -218,7 +193,7 @@ location ~ ^/static/(webseed|videos|redundancy|streaming-playlists)/ { aio threads; # web-videos is the name of the directory mapped to the `storage.web_videos` key in your PeerTube configuration - rewrite ^/static/webseed/(.*)$ /videos/$1 break; + rewrite ^/static/webseed/(.*)$ /web-videos/$1 break; rewrite ^/static/(.*)$ /$1 break; root __DATA_DIR__/storage/; diff --git a/conf/production.yaml b/conf/production.yaml index 74ab8ce..c9109bf 100644 --- a/conf/production.yaml +++ b/conf/production.yaml @@ -141,7 +141,7 @@ storage: tmp_persistent: '__DATA_DIR__/storage/tmp-persistent/' # As tmp but the directory is not cleaned up between PeerTube restarts bin: '__DATA_DIR__/storage/bin/' avatars: '__DATA_DIR__/storage/avatars/' - web_videos: '__DATA_DIR__/storage/videos/' + web_videos: '__DATA_DIR__/storage/web-videos/' streaming_playlists: '__DATA_DIR__/storage/streaming-playlists/' redundancy: '__DATA_DIR__/storage/redundancy/' logs: '/var/log/__APP__/' @@ -212,7 +212,7 @@ object_storage: # Same settings but for web videos web_videos: - bucket_name: 'videos' + bucket_name: 'web-videos' prefix: '' base_url: '' diff --git a/scripts/upgrade b/scripts/upgrade index fe2ddc7..522c6c8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,6 +53,11 @@ fi # Remove old log file ynh_secure_remove --file="$data_dir/logs" +# directory on filesystem must be renamed from videos/ to web-videos/ to represent the value of storage.web_videos +if [ -d "$data_dir/storage/videos" ]; then + mv $data_dir/storage/videos $data_dir/storage/web-videos +fi + #================================================= # STOP SYSTEMD SERVICE #=================================================