> 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/access-control/how-it-works.md).

# 工作原理

通用访问控制规则的评估顺序与四种动作的行为

## 规则评估 <a href="#request-flow" id="request-flow"></a>

规则按优先级逐条评估，未命中的继续下一条；命中后的去向由动作决定：

* **阻断、IP 封禁**：请求在这里结束。
* **挑战**：没有凭证的客户端收到验证页，请求结束；持有效凭证的客户端放行，不再评估本插件的后续规则。
* **跳过**：开启了**绕过剩余规则**时放行，不再评估后续规则；没开则继续下一条。

全部规则评估完仍未结束的请求进入下一个插件。条件字段见[条件匹配字段](/zh/docs/edge/policies/rules/condition-fields.md)，匹配方式见[操作符和函数](/zh/docs/edge/policies/rules/operators-and-functions.md)。

## 四种动作 <a href="#actions" id="actions"></a>

### 跳过 <a href="#skip-details" id="skip-details"></a>

放行本次请求。不开任何选项时请求继续评估后面的规则，但计入命中和「跳过」指标并产生日志，可用来在不拦截的情况下观察一条条件会命中多少请求。白名单规则需开启**绕过剩余规则**；**绕过速率控制插件**让请求不进入任何限速规则。两个选项独立。

### 阻断 <a href="#deny-details" id="deny-details"></a>

返回设定的状态码和页面，或断开连接，不回源。只拒绝这一个请求，下一个请求重新评估；已验证的 Bot 没有豁免。面向浏览器的路径用**返回页面**，被误拦的用户可以把页面上的 Request ID 报给您；扫描流量用**断开连接**。

### IP 封禁 <a href="#ban-details" id="ban-details"></a>

触发的请求连接直接关闭；封禁时长内该 IP 到这个节点的全部连接在内核层丢弃，不区分域名和端口。

* 和[速率控制的 IP 封禁](/zh/docs/edge/policies/rate-limiting/how-it-works.md#ip-ban-details)、挑战的自动封禁是同一套机制；边缘前面有 CDN 或负载均衡时不生效，见[真实客户端 IP](/zh/docs/edge/policies/real-ip.md#best-practices)。
* 按节点生效，不跨节点同步。
* 时长 1 秒到 1 年，到期自动解除，没有手动解封；禁用或删除规则只能阻止再次封禁。陷阱路径 300–600 秒，确认的攻击来源 600–3600 秒。
* 封禁期内的请求不进入处理，不产生日志，封禁记录见[洞察与日志 › IP 封禁记录](/zh/docs/edge/policies/access-control/insight.md#ban-records)。
* 已验证的 Bot 不会被封禁：命中 IP 封禁规则时被放行并继续评估后面的规则。

{% hint style="warning" %}
封禁不区分租户、域名和端口：同一出口 IP 后面的正常用户一起被拒绝，该 IP 访问这个节点上其它租户的站点也被拒绝。只在“请求这个路径的一定是攻击者”的条件上使用，时长宁短勿长。
{% endhint %}

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

返回验证页（403 Forbidden）；通过后下发凭证，有效期内这条规则不再挑战该客户端。

* **AxisNow 挑战**在浏览器里完成一次轻量的工作量证明，由边缘自己生成和校验；**第三方挑战**接入您的 [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/) 或 [Google reCAPTCHA](https://developers.google.com/recaptcha)，需先在设置里添加提供商。
* 凭证是加密的 HttpOnly Cookie，AxisNow 挑战为 `__ct_ac_alt`，第三方挑战为 `__ct_ac_cpt`（第三方挑战在验证页下发时另有 `__ct_ac_cpg`，5 分钟内有效，用于提交答案），有效期即**通过有效期**。凭证与这条规则、客户端 IP 和 TLS 指纹绑定，换 IP 或命中另一条挑战规则要重新验证。[速率控制的挑战](/zh/docs/edge/policies/rate-limiting/how-it-works.md#challenge-details)是同一套机制，Cookie 名为 `__ct_rl_alt`、`__ct_rl_cpt`，凭证相互独立。通过后「挑战通过」「AxisNow 挑战通过」「第三方挑战通过」字段置位，速率控制等后续插件可以用作条件。
* **自动封禁**：同一 IP 在窗口内被下发挑战的次数达到上限（默认 60 秒内 100 次）即封禁（默认 5 分钟），针对反复触发而不完成或轰炸验证接口的客户端。

{% hint style="warning" %}
第三方挑战的验证页在被挑战的站点域名下展示。在 Turnstile 或 reCAPTCHA 控制台创建站点密钥时，要把这些域名加入允许的域名列表，否则验证组件报错、无法通过。
{% endhint %}

#### 自适应挑战 <a href="#adaptive-challenge" id="adaptive-challenge"></a>

平时不验证、不打扰正常访客，请求量异常升高时自动开始挑战，流量回落后自动停止，用于全站兜底。

* **进入**：规则统计命中请求的 QPS（时间窗口内的平均值），达到**QPS 阈值**即进入挑战状态，对之后命中的请求发起挑战。
* **保持与退出**：挑战状态持续**保持时长**；保持期内 QPS 仍达到阈值则延长，回落后到期退出。
* **未进入时**：规则视为未命中，请求继续评估后面的规则。
* **计数范围**：按规则、按节点各自统计，阈值按单个节点承接的流量设定，取值方法见[防护场景 › 有攻击时自动开启挑战](/zh/docs/edge/policies/access-control/use-cases.md#adaptive)。

洞察页的命中时间线会标出挑战状态的时段，用于判断阈值是否合适。


---

# 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/access-control/how-it-works.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.
