zoukankan      html  css  js  c++  java
  • 如果用户没有登录,那么禁止下载文件

     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;
            }
  • 相关阅读:
    ubuntu18安装net-snmp
    virtual box安装ubuntu系统 ping通 && xshell可以连接
    高中操场所见所思
    如何写好研究生开题报告
    在加州考驾照
    一个软件工程项目竞赛网站
    结对项目总结
    喜马拉雅随车听开通啦
    裘老师赠书
    推荐博客链接
  • 原文地址:https://www.cnblogs.com/littlehb/p/4494012.html
Copyright © 2011-2022 走看看