> 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/ssl-tls/configuration.md).

# 配置项

SSL/TLS 规则的条件与六个动作

## 条件 <a href="#conditions" id="conditions"></a>

只能按「请求 Host」「域」「标签」划分，一条规则对应一个站点或一组站点。TLS 参数要在握手时确定，所以规则在两个阶段各匹配一次：

<table data-search="false"><thead><tr><th width="140">阶段</th><th width="220">生效的动作</th><th>「请求 Host」的取值</th></tr></thead><tbody><tr><td>TLS 握手</td><td>TLS 配置、H2 / H3 的协议协商、mTLS 客户端认证</td><td>ClientHello 里的 SNI</td></tr><tr><td>HTTP 请求</td><td>强制 HTTPS、HSTS、HTTP/3 的 Alt-Svc 头、源证书校验</td><td>Host 请求头</td></tr></tbody></table>

每个动作各取序号最小的命中规则，互不影响，见[插件 › 规则集](/zh/docs/edge/policies/rules.md#rulesets)。默认规则只配了 TLS 配置、强制 HTTPS 和 H2 / H3，其余三个动作没有规则命中就不启用。

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

一条规则按需添加动作，没添加的动作不受这条规则影响。

### TLS 配置 <a href="#tls-setting" id="tls-setting"></a>

限定握手时接受的 TLS 版本：**最低 TLS 版本**选 TLS 1.2 即只接受 1.2 和 1.3。

* 默认规则是 TLS 1.0，建议加一条条件为**任意**的规则把全部站点提到 TLS 1.2。
* 选 TLS 1.0 或 1.1 会让该规则命中的全部连接放开旧的加密套件，只给确有老设备的站点单独放开。

### 强制 HTTPS <a href="#force-https" id="force-https"></a>

HTTP 请求返回 301 Moved Permanently，跳转到同一 Host、路径和查询参数的 HTTPS 地址，请求结束，不进入后面的插件。

* 默认规则已开启，需要保留 HTTP 访问的站点用单独规则关闭。

### H2 / H3 <a href="#protocols" id="protocols"></a>

控制握手时向客户端提供的应用层协议。

* **HTTP2** 关闭后，ALPN 不再提供 h2，客户端用 HTTP/1.1。
* **HTTP3** 开启后，HTTPS 响应带 `Alt-Svc: h3=":443"; ma=86400`，浏览器从下一次连接起改用 QUIC，边缘前面的防火墙要放行 UDP 443；关闭后不接受 QUIC 连接，也不带 Alt-Svc 头。

### HSTS <a href="#hsts" id="hsts"></a>

HTTPS 响应带 `Strict-Transport-Security` 头，浏览器在 max-age 内把该域名的 HTTP 访问直接改写为 HTTPS。

* 要和强制 HTTPS 一起用：浏览器只认 HTTPS 响应里的这个头，首次 HTTP 访问要先被跳转到 HTTPS 才能收到。
* **最大实效时间**单位为秒，1 天到 1 年，先用较短的值观察；生效后证书错误的页面浏览器不再允许“继续访问”。
* **应用到子域名**覆盖该域名下的全部子域名，包括不在 AxisNow 上、只提供 HTTP 的内部站点。
* **预加载**只是在头里加 `preload` 指令，提交要到 hstspreload.org 手动完成，要求在注册域（如 `example.com`）上下发、max-age 不少于一年并应用到子域名；提交后移除需数月且不保证。

### mTLS 客户端认证 <a href="#client-mtls" id="client-mtls"></a>

握手时向客户端索取证书，按**可信证书颁发机构**里的 CA 校验签发链和有效期（不做吊销检查），结果写入「客户端证书验证状态」「客户端证书主题 DN」等条件字段。

* 校验不通过或客户端没有出示证书，握手照样完成，本插件不拒绝请求，校验结果只写入条件字段。
* CA 证书为 PEM 格式，多级 CA 都放进去，顺序无关。

### 源证书校验 <a href="#origin-tls-verify" id="origin-tls-verify"></a>

回源使用 HTTPS 时校验源站证书的有效期、证书链和域名，域名按回源时发送的 SNI 比对。校验不通过返回 502 Bad Gateway；配置的根证书无法加载时不回源，返回 500 Internal Server Error。

* **预置公共可信根证书列表**：源站证书由公共 CA 签发时选它。
* **自定义根证书**：自签或私有 CA 时选它，粘贴签发源站证书的 CA 根证书而不是源站证书，只取 PEM 里的第一张；多级 CA 时源站要在握手中发送中间证书。
* 回源 SNI 在[回源控制](/zh/docs/edge/policies/upstream-control/configuration.md#origin-rewrite)里改写，源站证书的域名要与之一致。
* 源站没有公共 CA 证书时，可在[端点 › 证书 › 最佳实践](/zh/docs/edge/endpoints/certificates/best-practices.md)手动申请一张部署到源站。


---

# 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/ssl-tls/configuration.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.
