You can do something like this; You'll have to find the explanations on nginx.org, but basacly it will forbid other that your own server to show the videos and limit the speed to 1mbit after 10 min
location ~ \.mp4$ {
#internal;
#alias /var/www/domain.tld/media/videos;
valid_referers none blocked server_names
domain.tld
*.domain.tld
if ($invalid_referer) {
rewrite ^ https://www.domain.tld/?;
}
secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires$remote_addr some_secrets";
if ($secure_link = "") {
rewrite ^ https://www.domain.tld/?;
}
if ($secure_link = "0") {
return 410;
}
mp4;
limit_rate_after 10m;
limit_rate 1M;
mp4_buffer_size 5m;
mp4_max_buffer_size 15m;
sendfile on;
aio on;
expires 18000;
add_header X-Frame-Options SAMEORIGIN;
}
location ~ \.mp4$ {
#internal;
#alias /var/www/domain.tld/media/videos;
valid_referers none blocked server_names
domain.tld
*.domain.tld
if ($invalid_referer) {
rewrite ^ https://www.domain.tld/?;
}
secure_link $arg_md5,$arg_expires;
secure_link_md5 "$secure_link_expires$remote_addr some_secrets";
if ($secure_link = "") {
rewrite ^ https://www.domain.tld/?;
}
if ($secure_link = "0") {
return 410;
}
mp4;
limit_rate_after 10m;
limit_rate 1M;
mp4_buffer_size 5m;
mp4_max_buffer_size 15m;
sendfile on;
aio on;
expires 18000;
add_header X-Frame-Options SAMEORIGIN;
}