> For the complete documentation index, see [llms.txt](https://www.axisnow.io/zh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.axisnow.io/zh/docs/edge/policies/rate-limiting/faq.md).

# 常见问题

速率控制使用中的常见疑问与排错

## 作用范围与计数 <a href="#scope" id="scope"></a>

<details>

<summary>规则是全局的还是按站点的？</summary>

规则作用于租户下所有 HTTP 和 HTTPS 端点。条件选**任意**就是全局；要限定站点，在条件里加**请求 Host**、**域**或**标签**。计数 Key 里加**请求 Host**则是另一回事：规则仍然对所有站点生效，只是每个站点各数各的。

</details>

<details>

<summary>规则命中率接近 100%，是不是配错了？</summary>

不一定。命中是请求匹配了条件、进入了计数；超限才是触发了动作。条件为**任意**的兜底规则命中率本来就很高，要看的是洞察页里阻断、观察等动作的数量，见[洞察与日志](/zh/docs/edge/policies/rate-limiting/insight.md)。

</details>

<details>

<summary>阈值设的 100，为什么来源发了一百多个请求才被拦？</summary>

三个原因可能叠加：计数按边缘节点独立，来源的请求分散到 K 个节点时总放行量约是阈值的 K 倍；计数按滑动窗口估算（上一窗口的计数按比例折算），而不是精确记录每个请求的时间，个别请求会有偏差；响应计数条件开启时只有满足条件的响应才计数。第一个原因是主要的，设阈值时按单个节点看到的流量考虑，见[工作原理 › 计数的作用域](/zh/docs/edge/policies/rate-limiting/how-it-works.md#scope)。

</details>

<details>

<summary>修改阈值或条件后，已有的计数会重置吗？</summary>

修改阈值或条件不会清空已有计数，已经处于限制期的 Key 也按原来的限制期到期。修改计数维度等于换了一套新的计数器；删除规则再新建则一切从零开始。

</details>

<details>

<summary>一个请求命中多条规则时怎么算？</summary>

按优先级依次评估，每条规则独立计数、独立判定。观察动作不中断评估；阻断、IP 封禁或挑战处置执行后，这个请求不再进入后面的规则。哪条先超限哪条生效，所以严格的规则放前面，见[防护场景 › 分层](/zh/docs/edge/policies/rate-limiting/use-cases.md#layering)。

</details>

<details>

<summary>命中缓存的请求也会被限速吗？</summary>

会。速率控制在缓存之前判定，命中缓存的请求同样计数、同样会被限制；响应计数条件也能看到缓存返回的状态码和响应头。

</details>

## 计数 Key 与响应计数 <a href="#counting-key" id="counting-key"></a>

<details>

<summary>能按 JSON 请求体里的字段计数吗？</summary>

不能。「POST 表单」维度只解析 `application/x-www-form-urlencoded` 的请求体，`multipart/form-data` 也取不到值。接口用 JSON 请求体时，可以让客户端把身份放进请求头、Cookie 或 URI 参数再按那个维度计数；取不到值的请求会落进同一个空值计数器，所以这类规则要配合一条按 IP 的规则。

</details>

<details>

<summary>「会话标识」是我业务的登录 Cookie 吗？</summary>

不是。「会话标识」读的是 AxisNow 边缘为浏览器访客下发的跟踪 Cookie，用于区分同一个公共出口 IP 后面的不同浏览器；请求没有这个 Cookie 时按客户端 IP 计数。要按您自己的登录态计数，用「匹配指定 Cookie 值」并填入您的 Cookie 名，或直接选常用组合里的「会话 Cookie」。

</details>

## 阻断与 IP 封禁 <a href="#block-and-ban" id="block-and-ban"></a>

<details>

<summary>阻断之后多久恢复？</summary>

从计数达到阈值那一刻起 N 秒（N 是规则的时间窗口），期间这个计数 Key 的请求都被拒绝，到期自动恢复计数。被拒绝的响应里 `X-RateLimit-Reset` 头给出的就是这个 N。持续高频的来源恢复后会很快再次触发。

</details>

<details>

<summary>客户端收到 429 之后应该怎么退避？</summary>

读响应头：`X-RateLimit: true` 表示请求已超限，`X-RateLimit-Limit` 是阈值，`X-RateLimit-Reset` 是限制期的长度（秒，固定等于规则的时间窗口，不是剩余秒数）。按 `X-RateLimit-Reset` 等待后重试即可。目前不返回 `Retry-After` 头，见[工作原理 › 响应头](/zh/docs/edge/policies/rate-limiting/how-it-works.md#response-headers)。

</details>

<details>

<summary>阻断响应体上传了 JSON，为什么 Content-Type 还是 text/html？</summary>

目前阻断响应的 `Content-Type` 固定为 `text/html; charset=utf-8`，不随上传文件的类型变化。正文内容会原样返回，客户端请按状态码和 `X-RateLimit` 头识别限速响应，再按约定解析正文，不要依赖 Content-Type。

</details>

<details>

<summary>IP 被封禁了，能手动解封吗？</summary>

目前没有手动解封的入口，封禁到期由节点自动解除。禁用或删除规则可以阻止再次封禁，已生效的封禁会持续到期满。IP 封禁的误伤面比阻断大，上线前请先用观察动作验证阈值，封禁时长从短的开始。

</details>

<details>

<summary>IP 封禁会同步到所有边缘节点吗？</summary>

不会。计数和封禁都按边缘节点各自生效，一个 IP 在哪个节点触发就只在那个节点被封，封禁记录里的**生效边缘**一列显示的就是它。同一个来源如果继续打其它节点，会在那些节点各自重新计数、各自触发。

</details>

## 挑战 <a href="#challenge" id="challenge"></a>

<details>

<summary>挑战对 API 请求有效吗？</summary>

无效。挑战返回的是一个要在浏览器里执行的验证页，只对页面导航请求有意义；XHR、fetch、移动端 SDK 和服务端调用拿到验证页只会报错。API 接口用阻断，让客户端根据 429 Too Many Requests 退避。

</details>

<details>

<summary>挑战的自动封禁「未通过 N 次」计的是什么？</summary>

计的是同一客户端 IP 在窗口内**被下发挑战的次数**，而不是作答失败的次数：拿到验证页不作答、反复刷新触发新挑战、轰炸验证接口，都会累加。所以它针对的是不完成验证的脚本，正常访客通过一次后在有效期内不会再被下发挑战，不会累计到这个上限。

</details>

## 豁免与排错 <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>怎么让监控探针、合作伙伴或搜索引擎不被限速？</summary>

推荐在通用访问控制里为它们配**跳过**规则并开启**绕过速率控制插件**，豁免名单集中维护；或者在某条限速规则的条件里排除它们，见[配置项 › 给可信来源豁免](/zh/docs/edge/policies/rate-limiting/configuration.md#allowlist)。已验证的搜索引擎等正常 Bot 对 IP 封禁动作自动豁免，但阻断没有这个豁免。

</details>

<details>

<summary>洞察页和日志为什么查不到某个请求？</summary>

依次排查：数据有约一分钟的延迟；日志检索经过采样，部分明细查不到，但指标不受采样影响；处于 IP 封禁期内的来源的请求不进入处理，不产生日志；观察动作下超限的请求在**观察请求**指标和日志里按动作**观察**筛选。

</details>

<details>

<summary>速率控制故障时会影响业务吗？</summary>

不会。计数器不可用时请求照常放行；速率控制是失败放行的，它的故障不会变成业务的故障。

</details>

## 其它 <a href="#misc" id="misc"></a>

<details>

<summary>TCP 转发端点可以限速吗？</summary>

不可以。速率控制只处理 HTTP 和 HTTPS 端点，TCP 转发端点不经过本插件。

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.axisnow.io/zh/docs/edge/policies/rate-limiting/faq.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
