在宝塔面板里用的 AI 爬虫屏蔽方案,Nginx 拦截

查看 43|回复 4
作者:QQOYrn3   
宝塔 Nginx 配置(推荐,复制即用)
操作步骤
宝塔 → 网站 → 选你的站点
设置 → 配置文件
在 server { ... } 里、所有 location 块之前 粘贴下面代码
保存 → 重载配置
[ol]
  • # ========== 屏蔽 AI / 数据采集爬虫 ==========
  • set $block_ai_bot 0;
  • if ($http_user_agent ~* "GPTBot")                          { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "ChatGPT-User")                     { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "OAI-SearchBot")                   { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "anthropic-ai")                     { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "ClaudeBot")                        { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "claude-web")                        { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Google-Extended")                  { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Applebot-Extended")                { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Bytespider")                        { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "CCBot")                            { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Amazonbot")                         { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "FacebookBot")                       { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "meta-externalagent")                { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "meta-externalfetcher")              { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "cohere-ai")                         { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Diffbot")                           { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "ImagesiftBot")                      { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Omgilibot")                         { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Omgili")                            { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "PerplexityBot")                     { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "YouBot")                            { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "AI2Bot")                            { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "PetalBot")                           { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "DataForSeoBot")                      { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "magpie-crawler")                     { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "img2dataset")                         { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Scrapy")                            { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "python-requests")                     { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "curl/")                              { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "wget")                               { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "HttpClient")                         { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Java/")                              { set $block_ai_bot 1; }
  • if ($http_user_agent ~* "Go-http-client")                    { set $block_ai_bot 1; }
  • if ($block_ai_bot = 1) {
  •     return 403;
  • }
  • # ========== 屏蔽结束 ==========[/ol]复制代码
    这方法好像有效

    宝塔, 爬虫

  • 美文苑文学网   
    宝塔NG免费防火墙不香吗?全可视化操作
    QQOYrn3
    OP
      
    美文苑文学网 发表于 2026-6-16 13:09
    宝塔NG免费防火墙不香吗?全可视化操作


    防不住
    美文苑文学网   
    QQOYrn3 发表于 2026-6-16 13:10
    防不住

    UA都是模拟的!哪有那么容易。能屏蔽一些就可以了。蜘蛛真太多了,加缓存加队列避免击穿到数据库
    YY八卦网   
    大善人呀 感谢分享
    您需要登录后才可以回帖 登录 | 立即注册

    返回顶部