> 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/upstream-control/configuration.md).

# 配置项

回源控制六个动作在界面之外需要了解的行为

条件里的「源域名」是域侧回源配置的 Host，在改写前求值；其余字段见[条件匹配字段](/zh/docs/edge/policies/rules/condition-fields.md)。

## 回源配置改写 <a href="#origin-rewrite" id="origin-rewrite"></a>

把命中的请求发往另一个源，覆盖域侧的回源配置。

* 源地址可以直接填写，也可以引用[源地址](/zh/docs/edge/endpoints/origin-address.md)对象以使用其负载均衡和健康检查。填写域名时在边缘解析，多个解析结果按负载均衡分发，解析失败时按域侧配置回源。
* 回源 Host 留空时保持域侧配置，不会随新源地址改变，新源站需要别的 Host 时要显式填写。`${{upstream_domain_address}}` 取域侧回源配置中的第一个源域名，域侧只配了 IP 时为请求的 Host。
* SNI 默认与回源 Host 相同，源站按另一个名字选择证书时单独填写。

## URL 改写 <a href="#url-rewrite" id="url-rewrite"></a>

只改边缘发往源站的 URL，客户端看到的地址和缓存 Key 仍按原始 URL。通配符方式只匹配路径、不区分大小写，`*` 可匹配空串；不匹配时路径不变，也不再匹配后面的 URL 改写规则。

## 回源请求 Header 改写 <a href="#header-rewrite" id="header-rewrite"></a>

添加在同名请求头之后追加一个，设置替换原值。`Host`、`Authorization`、`Cache-Control`、`Connection` 和 CORS 相关的标准请求头不能在这里改写，Host 用回源配置改写。边缘始终附加的请求头见 [HTTP 头与 Cookie](/zh/docs/edge/edge/headers-and-cookies.md#request-headers)。

## 缓冲区设置 <a href="#buffer" id="buffer"></a>

默认都开启，适合普通页面和接口。下面两类接口要关闭：

* **源响应缓冲区**，对流式输出的接口关闭：SSE、大模型对话的逐字输出、实时日志、进度推送。开启时边缘先收齐再发，客户端看到的是整段内容一次到达，或等不到数据而超时；关闭后源站发出的每一段立即送到客户端。源站也可以在响应里带 `X-Accel-Buffering: no`，对该响应单独关闭，不用配规则。
* **请求体缓冲区**，对大文件上传的路径关闭：开启时边缘要收完整个请求体才开始回源，大文件先写入边缘磁盘，源站看到的是上传“卡住”很久后突然完成，分片上传、边传边处理的接口尤其明显；关闭后边收边转发，不占用边缘存储，代价是请求体开始发送后回源失败不再重试。

{% hint style="warning" %}
关闭源响应缓冲区的请求不写入缓存：即使命中了可缓存规则，响应也不会保存，每次都回源，分片缓存同样不会保存；已有的副本仍可命中。只对流式接口的路径关闭，不要在覆盖面宽的规则里关闭。
{% endhint %}

## 回源重试 <a href="#retry" id="retry"></a>

回源失败时按负载均衡重新选择源地址再试。网络错误始终触发重试，状态码按勾选；非幂等请求默认不重试，开启前确认源站能承受重复请求。实际重试次数不超过源地址中的服务器数，单个地址时最多重试 2 次。支付、下单这类不能重复提交的接口用禁用重试。

## 连接复用与超时 <a href="#connection" id="connection"></a>

* **源连接池**：连接池按边缘的每个 worker 进程、每个源地址（协议、IP、端口，HTTPS 另按 SNI）各一个，连接池大小是单个 worker 对单个源地址保留的空闲连接上限，一个边缘对一个源地址的空闲连接总数约为该值乘以 worker 数，源站的连接上限要按此估算。关闭后每个请求新建连接。TCP 转发端点不复用连接。
* **回源超时**：读取超时是等待源站两次发送数据之间的最长时间，不是整个响应的时限。WebSocket 连接固定读写超时 3600 秒，不受此项影响。源站在内网或响应很快时可以把连接超时和读取超时调小，让故障更快暴露给重试。


---

# 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/upstream-control/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.
