server {} 里加入以下内容:


if ($http_referer ~* (^http://www.bvghfvg33..com$|secpass)) {
        return 405;
}


注:可以精确匹配,也可根据关键字匹配,分别使用不同的正则

curl 模拟来源访问

# curl  -e "secpas"  http://www.test.com/ -A "Mozilla/445.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>405 Method Not Allowed</title></head>
<body bgcolor="white">
<h1>405 Method Not Allowed</h1>
<p>The requested method is not allowed for the URL.</body>
</html>


返回HTTP CODE 405


注:curl -e " "  模拟来源
     curl -A " " 模拟UserAgent