百度云防护是一个不错的web应用防火墙 WAF,可以根据自己的需求拦截用户代理字符串(User-Agent),可针对恶意请求拦截有不错的效果。
今天主机帮就来教大家如何配置WAF规则拦截User-Agent。
首先,通过查看网站日志,找到需要拦截的User-Agent,如下图:

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/116.0.1938.76 Safari/537.36 就是用户代理字符串(User-Agent),每个用户请求都是有的。
我们找到需要拦截的User-Agent后,进入百度云防护 web规则设置里,开启自定义访问策略,添加策略。

然后我们输入
策略名称:User-Agent拦截
策略:User-Agent 等于 Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/116.0.1938.76 Safari/537.36
阻断类型:拦截
确定

这样我们就可以针对 Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/116.0.1938.76 Safari/537.36的User-Agent拦截了。
具体需要拦截哪些User-Agent,需要根据网站日志分析哪些请求是恶意的来拦截,这样只是举个例子给大家参考。