notice

当前位置: 系统之家 » 技术应用 » 阅读正文


Nginx 防盗链

2011年6月7日 | 发布: admin


点击图片查看更多内容

1. 针对不同的文件类型

#Preventing hot linking of images and other file types
location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip)$ {
    valid_referers none blocked server_names *.xtgly.com xtgly.com http://localhost baidu.com;
    if ($invalid_referer) {
        rewrite ^/ http://www.xtgly.com/images/default/logo.gif;
        # return 403;
    }
}

2. 针对不同的目录

location /img/ {
    root /data/www/wwwroot/bbs/img/;
    valid_referers none blocked server_names *.xtgly.com http://localhost baidu.com;
    if ($invalid_referer) {
        rewrite ^/ http://www.xtgly.com/images/default/logo.gif;
        #return 403;
    }
}

3. 同实现防盗链和expires的方法

#Preventing hot linking of images and other file types
location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip)$ {
    valid_referers none blocked server_names *.xtgly.com xtgly.com http://localhost ;
    if ($invalid_referer) {
        rewrite ^/ http://www.xtgly.com/images/default/logo.gif;
    }
    access_log off;
    root /data/www/wwwroot/bbs;
    expires 1d;
    break;
}
请对我们的文章进行评论

标签:

版权声明:

转载时请注明文章出处,并在文章结尾表明本文链接,特此声明!

本文链接:http://www.xtgly.com/1782.htm


1 trackbacks

  1. clairvoyant psychic readings Trackback | 2011/12/05