Nginx屏蔽或禁止指定来源网站访问
( 更新:04-12 加入收藏)
在nginx.conf的server配置项中加入
1.访问返回403
1.访问返回403
2.访问跳转指定网站if ($http_referer ~* "xxx.com") {
return 403;
}
3.禁止多域名if ($http_referer ~* "xxx.com") {
rewrite ^/ http://www.xxx.com/;
}
if ($http_referer ~* "xxx.com|aaa.com") {
rewrite ^/ http://www.xxx.com/;
}