成千上万的HTTP_REFERER不存在的域请求

在过去的几天里,我的一个网站每分钟都收到数百个请求,其中不存在随机域名为HTTP_REFERER和来自不同IP(因此使用deny from IP不是一个选项):

 REMOTE_ADDR | HTTP_REFERER | HTTP_USER_AGENT 95.133.126.178 | 1dljlc2jm2.info | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QihooBot 1.0 [email protected]) 188.232.31.38 | 3r28169e6v4.net | Mozilla/5.0 (compatible; ShunixBot/1.x; http://www.7vlc8pngqk7zmx.com/bot.htm) 177.184.135.114 | 3p10jjujbn.ru | Mozilla/5.0 (compatible; Bot; +http://w4n2e2mte8.ws/spamfilter 188.235.184.231 | 06d94hx.biz | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; iRider 2.21.1108; FDM) 42.119.240.12 | ho0gg8r7.net | Mozilla/3.0 (WorldGate Gazelle 3.5.1 build 11; FreeBSD2.2.8-STABLE) ... 

任何想法如何打这个,请?

更新 (问题成功解决后)

我的问题是不是我在DDoS下的重复。 我能做什么? 因为我知道“发生了什么” (小DDoS攻击),因此我已经要求准确的规则被添加到.htaccess来阻止攻击者。

顺便说一句,在这里我正在DDoS下。 我能做什么? build议联系主机提供商。 我做了,但我的托pipe服务提供商(最受欢迎的提供商之一)提议购买更昂贵的包,其中包含更多的资源。 🙂

Froggiz的解决scheme正是我所期待的。

这是阻止你的攻击者的规则

 # Block request if not empty or not start with http RewriteCond %{HTTP_REFERER} "!^$|^http" # Block request rule RewriteRule .* - [F] 

我已经添加了一些更多的规则来阻止其他机器人:

 # Block empty user agent, and suspect user agen RewriteCond %{HTTP_USER_AGENT} ^-?$|perl|python|\\x.*?\\x [NC,OR] # Limit request to GET POST and HEAD RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST)$ [OR] # Block request who doesn't start with / as it should for normal web sites RewriteCond %{REQUEST_URI} !^/ [OR] # Block request if not empty or not start with http RewriteCond %{HTTP_REFERER} "!^$|^http" # Redirect to 406 page RewriteRule .* - [END,R=406] 

我使用代码406(不可接受)作为响应代码,但它是可选的,它可以是所有你想要的[F]由apache doc

https://httpd.apache.org/docs/2.4/en/rewrite/access.html

如果你正在使用另一个重写规则(比如简短的url),你需要把我之前发布的规则放在第一个