31 # location ~* \.(gif|jpg|png|swf|flv)$ {
32 location ~ ^/(images)/ {
33 root /var/www/html/myci;
34 valid_referers none blocked localhost myci.local.com;
35 if ($invalid_referer) {
36 #rewrite ^/ http://www.ccvita.com/403.html;
37 #return 404;
38 #rewrite ~* \.(gif|jpg|png|swf|flv)$ nofind.jpg;
39 rewrite ^/ http://myci.local.com/nofind.jpg;
40 }
41 }
42
43
44 location ~ ^/(download)/ {
45 root /var/www/html/myci;
46 accesskey on;
47 accesskey_hashmethod md5;
48 #检查地址的哪个变量
49 accesskey_arg "key";
50 #md5加密的字符串
51 accesskey_signature "mypass$remote_addr";
52 #可以自定义错误提示页面
53 #error_page 403 = http://www.aslibra.com/?tips=download_not_permit;
54 }
download.php
<?php
1 $ipkey= md5("mypass".$_SERVER['REMOTE_ADDR']);
2 $output_add_key="<a href=http://myci.local.com/download/1.tar.gz?key=".$ipkey.">download_add_key</a><br />";
3 $output_org_url="<a href=http://myci.local.com/download/1.tar.gz>download_org_path</a><br />";
4 echo $output_add_key;
5 echo "<br>";
6 echo $output_org_url;
?>