Nginx禁止指定来源网站访问

在nginx.conf的server配置项中加入
1.访问返回403
if ($http_referer ~* "xxxxx.com") {
return 403;
}
2.访问跳转指定网站
if ($http_referer ~* "xxx.com") {
rewrite ^/ http://www.xxxxx.com/;
}
3.禁止多域名访问跳转指定网站
if ($http_referer ~* "xxx.com|ddd.com") {
rewrite ^/ http://www.xxxxx.com/;
}