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天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力 expires 3d; }