标签:防止 base local config figure 点击下载 设置 lsa usr
location /s/ { secure_link $arg_md5,$arg_expires; secure_link_md5 "$secure_link_expires$uri$remote_addr secret"; if ($secure_link = "") { return 403; } if ($secure_link = "0") { return 410; } ... }
# ./configure --with-http_secure_link_module --prefix=/usr/local/nginx-1.4.2 --with-http_stub_status_module # make # make install
server { listen 80; server_name s1.down.ttlsa.com; access_log /data/logs/nginx/s1.down.ttlsa.com.access.log main; index index.html index.php index.html; root /data/site/s1.down.ttlsa.com; location / { secure_link $arg_st,$arg_e; secure_link_md5 ttlsa.com$uri$arg_e; if ($secure_link = "") { return 403; } if ($secure_link = "0") { return 403; } } }
<?php # 作用:生成 nginx secure link 链接 # 站点: www.ttlsa.com # 作者:凉白开 # 时间: 2013-09-11 $secret = ‘ttlsa.com‘; # 密钥 $path = ‘/web/nginx-1.4.2.tar.gz‘; # 下载文件 # 下载到期时间,time 是当前时间,300 表示 300 秒,也就是说从现在到 300 秒之内文件不过期 $expire = time()+300; # 用文件路径、密钥、过期时间生成加密串 $md5 = base64_encode(md5($secret . $path . $expire, true)); $md5 = strtr($md5, ‘+/‘, ‘-_‘); $md5 = str_replace(‘=‘, ‘‘, $md5); # 加密后的下载地址 echo ‘<a href=http://s1.down.ttlsa.com/web/nginx-1.4.2.tar.gz?st=‘.$md5.‘&e=‘.$expire.‘>nginx-1.4.2</a>‘; echo ‘<br>http://s1.down.ttlsa.com/web/nginx-1.4.2.tar.gz?st=‘.$md5.‘&e=‘.$expire; ?>
标签:防止 base local config figure 点击下载 设置 lsa usr
原文地址:http://www.cnblogs.com/Aiapple/p/7367976.html