HTTP 头部重写
HTTP 头部重写功能允许用户添加、替换或删除与特定 URL 匹配的 HTTP 请求或响应的头部信息。需要 MITM 解密才能修改 HTTPS 流量。
添加头部信息
已存在则替换,不存在则添加。
-
match (string), 必填
URL 匹配正则表达式。
-
name (string), 必填
要添加的 Header 名称。
-
value (string), 必填
要添加的 Header 值。
-
type (string), 可选
作用于请求
request或响应response,默认request。 -
disabled (bool), 可选
是否禁用此规则。
配置示例
header_rewrites:
- add:
match: "^https://example\\.com"
name: X-Custom-Header
value: custom-value
type: request
替换头部信息
语义上用于替换已有头部的值。实际行为与 add 相同:已存在则替换,不存在则添加。
-
match (string), 必填
URL 匹配正则表达式。
-
name (string), 必填
要替换的 Header 名称。
-
value (string), 必填
替换的 Header 新值。
-
type (string), 可选
作用于请求
request或响应response,默认request。 -
disabled (bool), 可选
是否禁用此规则。
配置示例
header_rewrites:
- replace:
match: "^https://api\\.example\\.com"
name: Cache-Control
value: no-cache
type: response
删除头部信息
-
match (string), 必填
URL 匹配正则表达式。
-
name (string), 必填
要删除的 Header 名称。
-
type (string), 可选
作用于请求
request或响应response,默认request。 -
disabled (bool), 可选
是否禁用此规则。
配置示例
header_rewrites:
- delete:
match: ".*"
name: X-Tracking-Id
type: request