> 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/use-cases.md).

# 防护场景

通用访问控制的典型防护场景与可直接套用的规则参数

以下是典型用例，供参考，按站点情况取舍与组合；各表里的 IP、路径、域名都是示例值。规则的先后见页末的[分层](#layering)。

## 后台只允许已知 IP <a href="#allowlist" id="allowlist"></a>

后台、运维入口只允许办公网和 VPN 出口访问，其余来源阻断。

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>www.example.com</code>，并且 请求 URI 路径 通配符匹配 <code>/admin/*</code>，并且 客户端 IP 地址 不在以下各项之中 <code>203.0.113.0/24</code>、<code>198.51.100.7</code></td></tr><tr><td>动作</td><td>阻断，返回页面，403</td></tr></tbody></table>

## 按地区和 ASN 控制 <a href="#geo" id="geo"></a>

只服务目标市场，或攻击期间临时拦截某个国家、某个云厂商的 ASN。

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>www.example.com</code>，并且 客户端 IP 区域 不在以下各项之中 中国、新加坡。拦云厂商时换成 客户端 IP ASN 在以下各项之中 <code>16509</code>、<code>14618</code></td></tr><tr><td>动作</td><td>阻断，返回页面，403</td></tr></tbody></table>

## 可信来源跳过全部规则 <a href="#trusted" id="trusted"></a>

监控探针、合作伙伴的固定 IP 放在最前面跳过，不受后面任何规则和限速影响：

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>客户端 IP 地址 在以下各项之中 <code>192.0.2.0/24</code></td></tr><tr><td>动作</td><td>跳过，开启 绕过剩余规则 和 绕过速率控制插件</td></tr></tbody></table>

搜索引擎用「已验证的 Bot」放行，不按 IP 或 User Agent：

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>已验证的 Bot 等于 true</td></tr><tr><td>动作</td><td>跳过，开启 绕过剩余规则 和 绕过速率控制插件</td></tr></tbody></table>

## 要求特定请求头或 Cookie <a href="#require-header" id="require-header"></a>

只有带约定凭据的请求才放行，其余在边缘直接断开。正常客户端一定会带的请求头或 Cookie 都可以作为条件，攻击流量通常不带，对 CC 攻击很有效。

接口要求 `Authorization` 头：

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>api.example.com</code>，并且 请求头 <code>authorization</code> 不存在</td></tr><tr><td>动作</td><td>阻断，断开连接</td></tr></tbody></table>

测试站只对持约定 Cookie 的人开放，两条规则，跳过在前：

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>dev.example.com</code>，并且 匹配指定 Cookie 值 <code>devaccess</code> 等于 <code>k7f2…</code></td></tr><tr><td>动作</td><td>跳过，开启 绕过剩余规则</td></tr></tbody></table>

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>dev.example.com</code></td></tr><tr><td>动作</td><td>阻断，返回页面，403</td></tr></tbody></table>

图片防盗链：

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>www.example.com</code>，并且 文件后缀 在以下各项之中 <code>jpg</code>、<code>png</code>、<code>webp</code>，并且 请求头 referer 存在，并且 请求头 referer 不包含字符 <code>example.com</code></td></tr><tr><td>动作</td><td>阻断，断开连接</td></tr></tbody></table>

## 拦截扫描器噪音 <a href="#scanners" id="scanners"></a>

探测不存在的路径就阻断，命中陷阱路径就 IP 封禁；换 IP 不换工具的扫描器可以按「TLS 客户端 JA4 指纹」阻断。

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 URI 路径 开头为 <code>/.env</code>、<code>/.git/</code>、<code>/phpmyadmin/</code>、<code>/autodiscover/</code>（不加 Host，对全租户生效）</td></tr><tr><td>动作</td><td>阻断，断开连接</td></tr></tbody></table>

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 URI 路径 在以下各项之中 <code>/.env</code>、<code>/.git/config</code></td></tr><tr><td>动作</td><td>IP 封禁，600 秒</td></tr></tbody></table>

## 对可疑流量挑战 <a href="#challenge" id="challenge"></a>

来源可疑但不能确定是攻击时，让客户端做一次验证。条件排除静态文件和 API 路径，否则页面里的脚本、图片和接口请求收到验证页会加载失败。

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>www.example.com</code>，并且 请求 URI 路径 开头不是 <code>/api/</code>，并且 文件后缀 不在以下各项之中 <code>js</code>、<code>css</code>、<code>png</code>、<code>jpg</code>、<code>webp</code>、<code>svg</code>、<code>ico</code>、<code>woff2</code>，并且 客户端 IP 区域 不在以下各项之中 中国，并且 已验证的 Bot 等于 false</td></tr><tr><td>动作</td><td>挑战，AxisNow 挑战，通过有效期 24 小时</td></tr></tbody></table>

## 有攻击时自动开启挑战 <a href="#adaptive" id="adaptive"></a>

平时不验证，不影响正常用户；疑似攻击、请求量超过阈值时自动进入挑战状态，流量回落后自动退出。这是我们自己的官网和控制台的配置（域名已换成示例）。

<table data-search="false"><thead><tr><th width="140">配置项</th><th>取值</th></tr></thead><tbody><tr><td>条件</td><td>请求 Host 在以下各项之中 <code>www.example.com</code>，并且 请求 URI 路径 开头不是 <code>/api/</code>，并且 文件后缀 不在以下各项之中 <code>js</code>、<code>css</code>、<code>png</code>、<code>jpg</code>、<code>webp</code>、<code>svg</code>、<code>ico</code>、<code>woff2</code>，并且 已验证的 Bot 等于 false</td></tr><tr><td>动作</td><td>挑战，开启 自适应挑战，QPS 阈值取单节点正常峰值的 3–5 倍，保持时长 5 分钟；AxisNow 挑战，通过有效期 24 小时</td></tr></tbody></table>

阈值在[洞察](/zh/docs/edge/insight.md)里看这个站点正常高峰的请求 QPS，按边缘节点数折算成单节点的量，取 3–5 倍。站点 QPS 含静态资源和接口请求，比规则实际统计的页面请求高，取到的是上限；上线后看命中时间线，长期不进入挑战状态就往下调。

## 分层 <a href="#layering" id="layering"></a>

<table data-search="false"><thead><tr><th width="60">序号</th><th width="200">规则</th><th width="120">动作</th><th>为什么在这个位置</th></tr></thead><tbody><tr><td>1</td><td>可信来源、已验证的 Bot</td><td>跳过，绕过剩余规则</td><td>豁免必须在所有拦截之前</td></tr><tr><td>2</td><td>陷阱路径</td><td>IP 封禁</td><td>最确定的攻击来源最早处理</td></tr><tr><td>3</td><td>后台已知 IP、探测路径、地区、请求头与 Cookie</td><td>阻断</td><td>动作相同，先后无关</td></tr><tr><td>4</td><td>可疑流量</td><td>挑战</td><td>不应到达的请求已被拦截，剩下的才值得一次验证；持有效凭证的请求放行后不再匹配后面的规则，挑战在前面会绕过后面的阻断</td></tr><tr><td>5</td><td>全站自适应挑战</td><td>挑战</td><td>兜底，平时不动作</td></tr></tbody></table>


---

# 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/use-cases.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.
