Username Availability Check Stuck During Registration

在尝试于网站 https://it6.cc/ 注册时,用户名可用性检查卡住了。“正在检查用户名可用性…”的消息出现并长时间显示,阻止了正常的注册流程。


我找到了问题的原因,是因为 Cloudflare WAF 规则,
原始规则

(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/")

这是 Claude AI 优化后的规则,解决了这个问题

(cf.threat_score ge 10 and not cf.client.bot) or
(http.request.version eq "HTTP/1.0") or
(not http.user_agent contains "Mozilla/" and not cf.client.bot)
更改说明

Cloudflare 防火墙规则分析与优化

当前规则:

复制

(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/")

分析:

  1. cf.threat_score ge 5 and not cf.client.bot:这部分是合理的,阻止了高风险但非机器人的客户端。
  2. not http.request.version in {"HTTP/1.2" "HTTP/2" "HTTP/3" "SPDY/3.1"}:这可能过于严格,可能会阻止合法的旧版客户端。
  3. not http.user_agent contains "Mozilla/":这可能会阻止来自非浏览器客户端或 API 调用的合法请求。

优化后的规则:

复制

(cf.threat_score ge 10 and not cf.client.bot) or
(http.request.version eq "HTTP/1.0") or
(not http.user_agent contains "Mozilla/" and not cf.client.bot)

更改说明:

  1. 将威胁分数阈值提高到 10,以允许更多合法流量。
  2. 仅阻止 HTTP/1.0,允许更新的版本和 SPDY。
  3. 修改了用户代理检查,使其仅适用于非机器人流量,允许 API 调用和合法的非浏览器客户端。

其他注意事项:

  • 为用户名检查使用的特定路径或端点添加例外:

复制

and not (http.request.uri.path contains "/check_username")
  • 列出已知良好的 IP 地址范围或您大部分用户所在的国家/地区。
  • 考虑为某些条件实施速率限制,而不是完全阻止。

实施:

用优化后的版本替换您当前的规则,并监控其效果。根据您的流量模式和安全要求进行调整。

1 个赞