nginx secure_link_module 访问包含
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /opt/app/code;
location / {
secure_link $arg_md5,$arg_expires; # _md5,_expires 连接参数名对应的值 /download?md5=e4Nc3Rm01TBBNYw&expires=1539792000
secure_link_md5(加密方式) "$secure_link_expires$uri imooc"; # 取expires和url 和 imooc字符串进行加密
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 410;
}
}
}
url.sh
servername="jeson.t.imooc.io"
download_file="/download/file.img"
time_num=$(date -d "2018-10-18 00:00:00" +%s)
secret_num="imoocc"
res=$(echo -n "${time_num}${download_file} ${secret_num}"|openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =)
echo "http://${servername}${download_file}?md5=${res}&expires=${time_num}"