首页/技术代码/ 放两个Cloudflare防火墙策略,能挡住95%以上恶意流量

放两个Cloudflare防火墙策略,能挡住95%以上恶意流量

作者:神奇   分类:技术代码   时间:2022-10-19 18:43:27  标签:


放两个Cloudflare防火墙策略,能挡住95%以上恶意流量。
域名 》防火墙 》防护墙规则 》 创建防火墙规则,如图:

表达式:
(cf.threat_score ge 5 and not cf.client.bot) or (not http.request.version in {"HTTP/1.2" "HTTP/2" "HTTP/3" "SPDY/3.1"}) or (not http.user_agent contains "Mozilla/")

上面的意思是威胁分数大于或等于5,且不是已知的合法爬虫,会质询; HTTP版本不是 “HTTP/1.2” “HTTP/2” “HTTP/3” “SPDY/3.1” 会质询; 请求头不带 Mozilla/ 会质询; 上面可能会误伤爬虫,那么再创建一个合法爬虫规则 表达式:

(cf.client.bot) or (http.user_agent contains "duckduckgo") or (http.user_agent contains "FBexternalhit") or (http.user_agent contains "Feedfetcher-Google") or (http.user_agent contains "LinkedInBot") or (http.user_agent contains "Mediapartners-Google") or (http.user_agent contains "msnbot") or (http.user_agent contains "Slackbot") or (http.user_agent contains "推特Bot") or (http.user_agent contains "ia_archive") or (http.user_agent contains "yahoo")

上面的合法爬虫允许访问。
实测,这两条规则能挡住95%以上的CC攻击,然后防火墙设置,安全级别建议设置为低,否则影响浏览体验。

还是那句话,任何攻击都有特征的,分析日志,然后对应屏蔽才是最好的办法。

(cf.client.bot) or (http.user_agent contains "duckduckgo") or (http.user_agent contains "FBexternalhit") or (http.user_agent contains "Feedfetcher-Google") or (http.user_agent contains "LinkedInBot") or (http.user_agent contains "Mediapartners-Google") or (http.user_agent contains "msnbot") or (http.user_agent contains "Slackbot") or (http.user_agent contains "推特Bot") or (http.user_agent contains "ia_archive") or (http.user_agent contains "yahoo")


温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,谢谢合作!

评论:

发表评论:

code