一、查看配置
登录 CDN 控制台,在菜单栏里选择域名管理,单击域名右侧管理,即可在回源配置中看到回源 HTTP 请求头配置,默认情况下为开启状态。
二、操作类型
| 操作类型 | 说明 |
| 设置 | 变更指定请求头部参数的取值为设置后的值。若设置的头部不存在,则会增加该头部。若回源同名的头部已存在,则会覆盖原有的值。 |
| 增加 | 增加指定的回源请求头部参数。若设置的同名的头部已存在,则会追加新的值。 |
| 删除 | 删除指定的请求头参数。 |
三、头部参数
| 头部参数 | 说明 |
| X-Forward-Port | 用于携带用户端真实端口的头部。其值默认为 $remote_port 变量,不允许修改。 |
| Tencent-Acceleration-Domain-Name | 用于携带用户加速域名的头部,其值为 $host 变量。 |
| 自定义头部 | 自定义头部的Key 值长度默认为1 – 100个字符,由数字0 – 9、字符a – z、A – Z,及特殊符 – 组成。Value 长度为1 – 1000个字符,不支持中文。若头部取值为变量,当前仅支持配置 $remote_port 、 $client_ip 。 部分标准头部不支持自助设置/增加/删除,具体清单请参见文档注意事项。 |
四、配置示例
若加速域名 cloud.tencent.com 的回源 HTTP 请求头配置如下:
若访问资源为:http://cloud.tencent.com/test/test.mp4
命中 mp4 文件后缀及 /test 目录,因为是同一头部操作类型 – 增加,则底部优先级大于顶部,因此增加 x-cdn:Tencent 头部。
五、注意事项
以下标准头部暂时不支持设置/增加/删除回源 HTTP 请求头:
| www-authenticate | authorization | proxy-authenticate | proxy-authorization |
| age | cache-control | clear-site-data | expires |
| pragma | warning | accept-ch | accept-ch-lifetime |
| early-data | content-dpr | dpr | device-memory |
| save-data | viewport-width | width | last-modified |
| etag | if-match | if-none-match | if-modified-since |
| if-unmodified-since | vary | connection | keep-alive |
| accept | accept-charset | expect | max-forwards |
| access-control-allow-origin | access-control-max-age | access-control-allow-headers | access-control-allow-methods |
| access-control-expose-headers | access-control-allow-credentials | access-control-request-headers | access-control-request-method |
| origin | timing-allow-origin | dnt | tk |
| content-disposition | content-length | content-type | content-encoding |
| content-language | content-location | forwarded | x-forwarded-host |
| x-forwarded-proto | via | from | host |
| referer-policy | allow | server | accept-ranges |
| range | if-range | content-range | cross-origin-embedder-policy |
| cross-origin-opener-policy | cross-origin-resource-policy | content-security-policy | content-security-policy-report-only |
| expect-ct | feature-policy | strict-transport-security | upgrade-insecure-requests |
| x-content-type-options | x-download-options | x-frame-options(xfo) | x-permitted-cross-domain-policies |
| x-powered-by | x-xss-protection | public-key-pins | public-key-pins-report-only |
| sec-fetch-site | sec-fetch-mode | sec-fetch-user | sec-fetch-dest |
| last-event-id | nel | ping-from | ping-to |
| report-to | transfer-encoding | te | trailer |
| sec-websocket-key | sec-websocket-extensions | sec-websocket-accept | sec-websocket-protocol |
| sec-websocket-version | accept-push-policy | accept-signature | alt-svc |
| date | large-allocation | link | push-policy |
| retry-after | signature | signed-headers | server-timing |
| service-worker-allowed | sourcemap | upgrade | x-dns-prefetch-control |
| x-firefox-spdy | x-pingback | x-requested-with | x-robots-tag |
| x-ua-compatible | max-age | | |