对请求图片进行防盗链配置;
location ~* \.(gif|jpg|png|swf|flv)$ {
valid_referers none blocked www.xxx.com ; 配置白名单host
if ($invalid_referer) {
return 403;
}
}
针对图片目录进行防盗链配置;
location /images/ {
alias /data/images/;
valid_referers none blocked server_names www.xxx.com ; 配置白名单host
if ($invalid_referer) {return 403;}
}
设置目录访问控制:
location /directory_name/{
allow 127.0.0.1;
allow xx.xx.xx.xx; 不分先后顺序
deny all;
}
根据useragent访问
if ($http_user_agent = 'Spilder'){
return 403;
}