Update nginx template

Add rate limit to download and private static files
This commit is contained in:
Chocobozzz 2022-10-25 15:48:00 +02:00
parent ae7b0cbbcf
commit 216fa9d579
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 13 additions and 5 deletions

View File

@ -214,8 +214,16 @@ server {
try_files $uri @api; try_files $uri @api;
} }
location ~ ^/static/(webseed|streaming-playlists)/private/ { location ~ ^(/static/(webseed|streaming-playlists)/private/)|^/download {
try_files /dev/null @api; # 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;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_limit_rate 5M;
proxy_pass http://backend;
} }
# Bypass PeerTube for performance reasons. Optional. # Bypass PeerTube for performance reasons. Optional.
@ -231,9 +239,9 @@ server {
} }
# Use this line with nginx >= 1.17.0 # Use this line with nginx >= 1.17.0
#limit_rate $peertube_limit_rate; limit_rate $peertube_limit_rate;
# Or this line if your nginx < 1.17.0 # Or this line with nginx < 1.17.0
set $limit_rate $peertube_limit_rate; # set $limit_rate $peertube_limit_rate;
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';