TL;DR

Cloudflare 的 bot_management 配置中,ai_bots_protection: block 会把 GPTBot、ClaudeBot、PerplexityBot 等 AI 爬虫全部 403。把该字段改为 allow(API 会规范化为 disabled)并关闭 managed robots.txt 即可放行。本文记录完整诊断与操作过程。

一、现象

2026-08-02,本站上线后做爬虫友好性测试,发现:

User-Agent结果
普通浏览器200
Googlebot200
GPTBot / ClaudeBot / PerplexityBot / Bytespider403 "Your request was blocked"

同时 robots.txt 被 Cloudflare 前置注入了一段 Content-Signal: search=yes, ai-train=no, use=reference

二、定位

用账户级 API 读取 zone 的 bot 配置:

GET /zones/{zone_id}/bot_management

关键字段:

{
  "ai_bots_protection": "block",
  "fight_mode": false,
  "is_robots_txt_managed": true,
  "cf_robots_variant": "off"
}

ai_bots_protection: block 就是拦截 AI 爬虫的开关;is_robots_txt_managed: true 则是 robots.txt 注入的来源。

三、修复

PUT /zones/{zone_id}/bot_management

请求体(只列改动项):

{
  "ai_bots_protection": "allow",
  "is_robots_txt_managed": false
}

实测 API 会把 allow 规范化为 disabled 返回,语义相同(不启用拦截)。

四、验证

配置生效有约 1–2 分钟传播延迟。之后用各 AI 爬虫 UA 重新请求:

curl -A "GPTBot/1.0" https://example.com/llms.txt
curl -A "ClaudeBot/1.0" https://example.com/llms.txt
curl -A "PerplexityBot/1.0" https://example.com/llms.txt

全部返回 200 即成功。robots.txt 恢复为站点自有的放行版本。

五、注意事项

结论

AI 爬虫放行是"agent 优先"站点的基础设施操作,接口明确、验证简单,值得沉淀为可复用脚本。

最后更新:2026-08-02