Location ~.*\. (html|htm|gif|jpeg|bmp|jpg|ico|js|css|flv|ttf|woff|eot|svg|shtml|png|doc|exe|docx|swf|wmv|zip|ppt|mpg|mp3|asf| pptx|asx|avi|bmp|dat|db|dot|fla|gsp|hlv|mht|mp2|mpa|mp4|mpv|pptm|psd|ram|rar|rm|rmvb|rtf|shs|tif|wmf|wav|wma| Xls|xlsx|pdf) $ {#防止盗链 Default_type application/octet-stream; Rewrite_by_lua'Local _, q=string. Find (ToString (ngx.var. Uri),"Dsideal_yy/html/down") if(Q ~=nil) then Ngx.log (NGX. ERR,"#########################".. Q); Local cookie_person_id= ToString (ngx.var. cookie_person_id); if(cookie_person_id = ="Nil") then Ngx.exit (NGX. Http_forbidden) End End'; if($arg _flag ="Download") {Add_header Cache-control"Private"; Add_header Accept-rangles"bytes"; Add_header Content-disposition"attachment;filename= $arg _n;filename*=utf-8 "$arg _n;"; Add_header Pragma"No-cache"; Add_header Expires"0"; } Root/usr/local/tomcat7/WebApps; #expires定义用户浏览器缓存的时间为3天, if the static page is not updated frequently, can be set longer, which can save bandwidth and relieve the pressure of the server expires 3d; }
If the user is not logged in, the download file is forbidden