# 为什么 semrushbot 和 ahrefsbot 默认被阻止？

**URL:** <https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682>\
**Category:** Support\
**Created:** [2020年七月14日 08:57 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682 "2020-07-14T08:57:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamie\_Liu1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamie_liu1/32/139694_2.png) [@Jamie\_Liu1](https://meta.discourse.org/u/Jamie_Liu1)\
**Post date:** [2020年七月14日 08:57 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/1 "2020-07-14T08:57:31Z")

</div>

我检查了 Google Search Console 的覆盖报告，发现我们论坛的许多页面都被 robots.txt 阻止了。于是我去查看了 robots.txt 文件，结果发现 semrushbot 和 ahrefsbot 默认被阻止了：

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/1/e1ec1bbdad12ab09235fa0e925bc62f3bd568a6a.png)

我知道这两个是广泛使用的 SEO 工具，为什么要阻止它们的爬虫呢？

---

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年七月14日 09:03 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/2 "2020-07-14T09:03:09Z")

</div>

> [@Jamie\_Liu1](#):
>
> 我知道这两个是广泛使用的 SEO 工具，为什么要屏蔽它们的爬虫呢？

因为这些爬虫是“资源吞噬型流氓机器人”，它们消耗大量服务器资源，却给网站带来的价值微乎其微。

当然，你可以自定义 Discourse 的 `robots.txt` 文件并在需要时允许它们访问；但我们在 Discourse 发布之前很久就已经在自己的网站上屏蔽了这些爬虫，并且一直保持着屏蔽状态。

🙂

* * *

备注（已编辑）：

我忘了提到，许多这类“资源吞噬型流氓机器人”并不遵守 `robots.txt` 规则，因此必须在 HTTP User Agent 层面进行屏蔽。一般来说，我们会在反向代理层面通过 `mod_rewrite` 来屏蔽这些“不守规矩的资源吞噬型流氓机器人”（顺便一提，这也是在反向代理后面运行的众多好处之一）。

---

<div class="post-metadata">

**Author:** ![Jamie\_Liu1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamie_liu1/32/139694_2.png) [@Jamie\_Liu1](https://meta.discourse.org/u/Jamie_Liu1)\
**Post date:** [2020年七月14日 09:29 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/3 "2020-07-14T09:29:10Z")

</div>

非常感谢提供的信息！

我又发现了一个问题，也许您也能分享一下您的见解。🙂

我知道 Discourse 默认已阻止用户页面，但在我的 Google Search Console 覆盖范围报告中，仍有一些用户页面被索引。这在 Google 看来是个问题，因为这些页面都不应被索引：

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/d/8d21a9974caad60694a9b0035253433cb6bbc342.png)

谢谢！

---

<div class="post-metadata">

**Author:** ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)\
**Post date:** [2020年七月14日 12:35 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/4 "2020-07-14T12:35:34Z")

</div>

这个问题最近已通过以下提交修复：

> <https://github.com/discourse/discourse/commit/13f229808a22db9e1032832a313ab701b66614c8>

请更新您的 Discourse 并重新验证。

---

<div class="post-metadata">

**Author:** ![Jamie\_Liu1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamie_liu1/32/139694_2.png) [@Jamie\_Liu1](https://meta.discourse.org/u/Jamie_Liu1)\
**Post date:** [2020年七月15日 02:14 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/6 "2020-07-15T02:14:06Z")

</div>

@osioke 感谢您的回复！我认为我们已安装的版本应该已经包含该功能了？因为我注意到该修复是在 1 月提交的。

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/b/1bba91bb6fa8b3c63f4298b773e3f551098c4c9e.png)

能否请您确认一下，我是否需要升级到最新版本才能使用该功能？

---

<div class="post-metadata">

**Author:** ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)\
**Post date:** [2020年七月15日 07:03 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/7 "2020-07-15T07:03:44Z")

</div>

依我看，更新一下也无妨，不过该修复确实应该包含在你已安装的版本中。我建议你尝试更新并重新验证，除非你因其他原因不想更新。

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2020年七月15日 21:41 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/8 "2020-07-15T21:41:18Z")

</div>

> [@Jamie\_Liu1](#):
>
> 我知道这两个是广泛使用的 SEO 工具，为什么要屏蔽它们的爬虫？

因为它们很糟糕？它们给服务器带来大量负载，却没有任何可辨识的好处，而且我们的客户套餐中确实有页面浏览量限制。

---

<div class="post-metadata">

**Author:** ![Jamie\_Liu1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jamie_liu1/32/139694_2.png) [@Jamie\_Liu1](https://meta.discourse.org/u/Jamie_Liu1)\
**Post date:** [2020年七月16日 02:13 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/9 "2020-07-16T02:13:27Z")

</div>

听起来不错。我们正在更新。希望更新后一切顺利。我会再联系并随时告知您进展。🙂 谢谢！

---

<div class="post-metadata">

**Author:** ![trying2survive](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@trying2survive](https://meta.discourse.org/u/trying2survive)\
**Post date:** [2020年十二月2日 15:30 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/10 "2020-12-02T15:30:00Z")

</div>

请澄清一下，是否无法解除对 Semrushbot 和 SEO Spider 的屏蔽？我们需要它们进行 SEO 审计。已尝试在 /admin/customize/robots 中移除这两者（也尝试过添加 Allow: 指令），但在 Screaming Frog 中仍收到 429 错误。这个 429 错误是否是一个独立的问题？非常感谢您的见解。

---

<div class="post-metadata">

**Author:** ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)\
**Post date:** [2020年十二月2日 16:34 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/11 "2020-12-02T16:34:12Z")

</div>

429 错误表示这些爬虫受到了速率限制。Discourse 默认启用了一些限流机制以防止滥用。您可以在此处了解更多相关信息。

> [@Available settings for global rate limits and throttling](https://meta.discourse.org/t/global-rate-limits-and-throttling-in-discourse/78612):
>
> Discourse ships with 3 different global rate limits that can be configured by site admins. Global per-ip rate limits These limits apply to every unique IP address that hits the Discourse application. (files that are served directly from the filesystem or the CDN are excluded) By default this rate limit is enabled, you may disable it or set it to a reporting mode. DISCOURSE\_MAX\_REQS\_PER\_IP\_MODE : default block, this rate limit applies out of the box. (other options are warn, warn+block, and n…

---

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年十二月3日 09:35 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/12 "2020-12-03T09:35:29Z")

</div>

> [@trying2survive](#):
>
> 澄清一下，是否无法解除对 semrushbot 和 seo spider 的封锁？

你试过这个方法吗（但请将容器名称替换为你自己的容器名称）？

注意：你也可以在管理界面（Admin UI）中配置此项：

```plaintext
# docker exec -it socket-only bash
root@socket-only:/# rails c
[1] pry(main)> SiteSetting.blocked_crawler_user_agents
=> "mauibot|semrushbot|ahrefsbot|blexbot|seo spider"
[2] pry(main)> SiteSetting.blocked_crawler_user_agents = ""
=> ""
[3] pry(main)> SiteSetting.blocked_crawler_user_agents
=> ""
[4] pry(main)> 

```

另请参阅：

> <https://github.com/discourse/discourse/blob/d1d87b6fa3f8279bb35d264c997d37a185aa75d9/config/site_settings.yml>

另请参阅：

```ruby
  def self.allow_crawler?(user_agent)
    return true if SiteSetting.allowed_crawler_user_agents.blank? &&
      SiteSetting.blocked_crawler_user_agents.blank?
...
...

```

> <https://github.com/discourse/discourse/blob/e0d9232259f6fb0f76bca471c4626178665ca24a/lib/crawler_detection.rb>

从代码中可以看出，如果你将这两个站点设置设为“空白”，则不会进行任何封锁：

- SiteSetting.allowed\_crawler\_user\_agents
- SiteSetting.blocked\_crawler\_user\_agents

我建议你 **不要修改** 这些设置，因为 Discourse 核心默认封锁的这些爬虫并不遵守 robots.txt 协议；不过，这是你的网站，你可以按自己的意愿操作。核心中默认封锁它们是有充分理由的。

话虽如此，Discourse 确实提供了通过 UI 中的站点设置（SiteSettings）来“解除封锁”这些爬虫的选项。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2021年一月2日 09:35 UTC](https://meta.discourse.org/t/why-semrushbot-and-ahrefsbot-are-blocked-by-default/157682/13 "2021-01-02T09:35:43Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
