一、内容
以下是目前 EdgeOne 支持的预设变量 – 从客户端 HTTP 请求中获取特定的字段或信息作为变量。
注意:说明:
| 名称 | 类型 | 说明 | 示例 |
| http.request.scheme | String | 客户端请求协议 | httphttps |
| http.request.zone | String | 站点名称 | example.com |
| http.request.zoneid | String | 站点 ID | zone-2c2r77pc3796 |
| http.request.host | String | 客户端请求 URI 中的 hostname | www.example.com |
| http.request.full_uri | String | 客户端请求的完整 URI(不包括#fragment) | https://www.example.org/articles/index?section=539061&expand=comments |
| http.request.method | String | 客户端请求 HTTP 方法 | GET |
| http.request.uri | String | 客户端请求的 URI 路径和查询字符串 | /articles/index?section=539061&expand=comments |
| http.request.uri.path | String | 客户端请求的 URI 路径 | /articles/index |
| http.request.file_extension | String | 客户端请求文件的文件后缀 | jpg |
| http.request.filename | String | 客户端请求文件的文件名 | bot.txt |
| http.request.uri.query | String | 客户端请求的整个查询字符串,不包括?分隔符 | section=539061&expand=comments |
| http.request.headers["key"] | String | 客户端请求指定头部名称为“key”的头部值,“key”可替换为你指定的名称。若指定的头部名称重复出现,则变量值以最后面的为准。 | 客户端请求 URL :https://developer.mozilla.org,携带头部 -H 'key: 123' -H 'key: 456',则变量获取到的值为 456 |
| http.request.uri.args["key"] | String | 客户端查询字符串指定参数名称为“key”的参数值,“key”可替换为你指定的名称。若指定的参数名称重复出现,则变量值以最后面的为准。 | 客户端请求 URL :https://developer.mozilla.org?key=123&key=456,则变量获取到的值为 456 |
| http.request.version | String | 客户端请求所使用的 HTTP 协议的版本 | HTTP/1.0HTTP/1.1HTTP/2HTTP/3 |
| http.request.ip | String | 客户端 TCP IP 地址,例如:1.1.1.1 | 93.184.216.34 |
| http.request.ip.port | String | 客户端源端口 | 1028 |
| http.request.ip.city | String | 与客户端 IP 地址相关联的城市 | San Francisco |
| http.request.ip.continent | String | 与客户端 IP 地址相关联的大洲代码 | AF: 非洲 (Africa)AS: 亚洲 (Asia)EU: 欧洲 (Europe)NA: 北美洲 (North America)SA: 南美洲 (South America)OC: 大洋洲 (Oceania)AN: 南极洲 (Antarctica) |
| http.request.ip.country | String | 与客户端 IP 地址相关联的以 ISO 3166-1 Alpha 2 格式的2字母国家代码 | GB,更多见 ISO 3166-1 Alpha 2 规范 |
| http.request.ip.asn | String | 用于获取客户端的 ASN 信息(介于 131072 和 4294967294 之间的 32 位数字) | 200000,更多见 ASN 规范 |
| http.request.ip.longitude | String | 用于获取客户端经度信息 | 118.767410 |
| http.request.ip.latitude | String | 用于获取客户端的纬度信息 | 32.041546 |
| http.request.ip.region_code | String | 用于获取客户端的地区代码信息 | CN-JS,更多见 地区代码&地区名称映射表 |
| http.request.ip.region_name | String | 用于获取客户端的地区名称信息 | Jiangsu,更多见 地区代码&地区名称映射表 |
二、使用示例
1. 自定义回源请求头部,携带客户端 IP 地址所在国家信息回源。
2. 自定义回源请求头部,源站收集和统计哪些域名是经过 Tencent EdgeOne 加速。
3. 自定义跨域请求策略:允许请求中 Origin 头部值的域名的跨域请求。
4. 自定义节点响应头:引用 URL 中 filename 参数的值以及拼接固定常量,作为响应头部 Content-Disposition 的值。