nginx防盗链配置

nginx防盗链配置的代码,默认跳转404页面,可配置跳转图片。

#SECURITY-START 防盗链配置
location ~ .*\.(jpg|jpeg|gif|png|js|css)$
{
    expires      30d;
    access_log /dev/null;
    valid_referers none blocked *.tanst.net www.tanst.net;
    if ($invalid_referer){
       #rewrite ^/ http://ww4.sinaimg.cn/bmiddle/051bbed1gw1egjc4xl7srj20cm08aaa6.jpg;
       return 404;
    }
}
#SECURITY-END

评论已关闭