mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
docs: explain reverse proxy query normalization
Some checks failed
Go Test / test (push) Has been cancelled
Some checks failed
Go Test / test (push) Has been cancelled
Clarify that outgoing proxy queries are normalized before forwarding, which may re-encode or drop non-standard fragments to keep parsing behavior consistent across proxy chains.
This commit is contained in:
parent
6d89b8674f
commit
8031e799d9
2 changed files with 7 additions and 0 deletions
|
|
@ -52,6 +52,8 @@ r.ANY("/api/*path", touka.ReverseProxy(touka.ReverseProxyConfig{
|
||||||
- `/api/orders?id=10` 会转发到 `/backend/api/orders?id=10`
|
- `/api/orders?id=10` 会转发到 `/backend/api/orders?id=10`
|
||||||
|
|
||||||
目标 URL 自身携带的查询参数也会被保留并与原请求查询参数合并。
|
目标 URL 自身携带的查询参数也会被保留并与原请求查询参数合并。
|
||||||
|
合并后的出站查询串会再经过一次规范化处理,因此某些非标准分隔符(例如 `;`)或非法参数片段可能被重编码、折叠或直接丢弃。
|
||||||
|
这是为了尽量让代理链各跳对查询参数的解析结果保持一致,并减少参数走私这类解析歧义风险。
|
||||||
|
|
||||||
## 配置项说明
|
## 配置项说明
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -910,6 +910,11 @@ func cleanReverseProxyQueryParams(rawQuery string) string {
|
||||||
if rawQuery == "" {
|
if rawQuery == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
// Normalize the outgoing query string so the proxy and upstream do not see
|
||||||
|
// different semantics for non-standard separators or malformed pairs.
|
||||||
|
// This can change the exact textual form of the original query and may drop
|
||||||
|
// parts that net/url rejects, but it keeps proxy-chain parsing behavior more
|
||||||
|
// consistent and reduces parameter-smuggling ambiguity.
|
||||||
values, _ := url.ParseQuery(rawQuery)
|
values, _ := url.ParseQuery(rawQuery)
|
||||||
return values.Encode()
|
return values.Encode()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue