我在CentOS上设置NGINX并设置配置文件以防止直接访问视频文件。 这是我使用的示例代码。
location /videos/ {
valid_referers none blocked abccc.com;
if ($invalid_referer) {
return 403;
}
root /var/cdn/videos/;
## This must match the URI part related to the MD5 hash and expiration time.
secure_link $arg_st,$arg_e;
## The MD5 hash is built from our secret token, the URI($path in PHP) and our expiration time.
secure_link_md5 Gf1Pv52EifS1f8G9agn2k2n8a$uri$arg_e;
## If the hash is incorrect then $secure_link is a null string.
if ($secure_link = "") {
return 403;
}
## The current local time is greater than the specified expiration time.
if ($secure_link = "0") {
return 403;
}
gzip off;
gzip_static off;
mp4;
flv;
mp4_buffer_size 5M;
mp4_max_buffer_size 10M;
#mp4_limit_rate on;
#mp4_limit_rate_after 30s;
## If everything is ok $secure_link is 1.
rewrite ^/videos/(.*)$ /videos/$1 break;
}
但是当重新启动服务器并测试它时,我仍然可以访问文件夹中的视频文件 直接网址和安全链接。
另外,当我尝试在localhost中使用此配置时,它可以正常工作。
我做错了什么?