码迷,mamicode.com
首页 > 其他好文 > 详细

配置防盗链

时间:2019-01-28 12:05:21      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:白名单   files   定义   roc   www.   51cto   通过   https   txt   

通过限制referer来实现防盗链的功能
配置文件增加如下内容:vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

  <Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref     //定义白名单
        SetEnvIfNoCase Referer "http://aaa.com" local_ref
        SetEnvIfNoCase Referer "^$" local_ref
        <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">     //定义规则
            Order Allow,Deny      //定义顺序,允许或者拒绝
            Allow from env=local_ref
        </FilesMatch>
    </Directory>

技术分享图片

浏览器访问显示:
技术分享图片

curl -e "http://www.qq.com/123.html" 自定义referer
curl -e "http://www.qq.com/123.html" -x127.0.0.1:80 111.com/qq.png -I
技术分享图片

curl -e "http://aaa.com/123.txt" -x127.0.0.1:80 111.com/qq.png -I 正常

配置防盗链

标签:白名单   files   定义   roc   www.   51cto   通过   https   txt   

原文地址:http://blog.51cto.com/14079728/2347121

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!