变量

最近更新时间:2025-11-18 11:30:42

我的收藏

简介

配置中,变量允许您动态提取和处理请求中的数据。这些变量不仅可以存储静态值,还可以引用请求中的特定字段或信息,其值在处理每个请求时都可能变化。例如:http.request.host 变量,它可以提取每个 HTTP 请求中的 hostname。这种能力使规则引擎能够处理更复杂的业务逻辑。

内容

以下是目前 EdgeOne 支持的预设变量 - 从客户端 HTTP 请求中获取特定的字段或信息作为变量。
说明:
使用变量时,请遵循以下格式:${http.request.scheme}。若格式或名称不正确,则无法成功使用变量。
目前仅支持单独使用变量,不允许变量与常量,或变量 A 与变量 B 拼接等形式。
名称
类型
说明
示例
可使用模块
http.request.scheme
String
客户端请求协议(应用层协议 HTTP/HTTPS)
http

https
站点加速,
Web 防护
http.request.zone
String
站点名称
example.com
站点加速
http.request.zoneid
String
站点 ID
zone-2c2r77pc3796
站点加速
http.request.host
String
客户端请求 URI 中的 hostname
www.example.com
站点加速,
Web 防护
http.request.full_uri
String
客户端请求的完整 URI(不包括 #fragment)
https://www.example.org/articles/index?section=539061&expand=comments
站点加速
http.request.method
String
客户端请求 HTTP 方法(Method)
GET
站点加速,
Web 防护
http.request.uri
String
客户端请求的 URI 路径和查询字符串(包含 Path + Argument,不包含 Scheme 和 Host)
/articles/index?section=539061&expand=comments
站点加速,
Web 防护
http.request.uri.path
String
客户端请求的 URI 路径
/articles/index
站点加速,
Web 防护
http.request.file_extension
String
客户端请求文件的文件后缀
jpg
站点加速,
Web 防护 (with additional '.')
http.request.filename
String
客户端请求文件的文件名
bot.txt
站点加速
http.request.uri.query
String
客户端请求的整个查询字符串,不包括?分隔符
section=539061&expand=comments
站点加速,
Web 防护
http.request.headers["key"]
String
客户端请求指定头部名称为 “key” 的头部值,“key” 可替换为您指定的名称
https://developer.mozilla.org
站点加速,
Web 防护
http.request.uri.args["key"]
String
客户端查询字符串指定参数名称为 “key” 的参数值,“key” 可替换为您指定的名称
value
站点加速
http.request.version
String
客户端请求所使用的 HTTP 协议的版本
HTTP/1.0

HTTP/1.1

HTTP/2

HTTP/3
站点加速
http.request.ip
String
客户端 TCP IP 地址,例如:1.1.1.1
93.184.216.34
站点加速,
Web 防护
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 规范]
站点加速,
Web 防护 (planned)
http.request.ip.version
Integer
客户端请求的 IP 协议版本(网络层协议 IPv4/IPv6)
4

6
Web 防护
http.request.xff_header_ip
String
当请求中包含 X-Forwarded-For 头部时,为 X-Forwarded-For 头部中第一个 IP,即被代理的原始客户端 IP;当请求中不包含 X-Forwarded-For 头部时,为请求的客户端 IP。
93.184.216.34
Web 防护
http.request.cookies["key"]
String
客户端请求中指定名称为 “key” 的 Cookie 会话值,“key” 可替换为您指定的名称
MySessionId
Web 防护
http.request.ja3
String
客户端请求的 JA3 指纹(TLS 指纹)
e7d705a3286e19ea42f587b344ee6865
Web 防护
http.request.ip.reputation
String
客户端 IP 的信誉度(客户端画像分析),包括历史恶意行为类型和信誉置信度。
scanners.medium
Web 防护
http.request.ip.isp
String
客户端 IP 所属的运营机构
chinatelecom.com
Web 防护
http.request.bot.search_engine_bot
String
客户端请求来源的搜索引擎爬虫分类
googlebot_image
Web 防护
http.request.bot.known_bot_type
String
客户端请求的 User-Agent 头部所表示的已知爬虫类型
web_developer_tools
Web 防护
http.request.bot.behavioral_analysis.tag
String
客户端请求的智能分析结果分类
malicious_bot

suspected_bot
Web 防护
http.request.bot.behavioral_analysis.rule_id
String
客户端请求的智能分析的详细特征 ID
botba-1320255933
Web 防护
http.request.bot.session
Object
客户端请求中所包含的 Bot 会话信息。包括会话的详细特征:
status:会话状态
ip:会话的初始 IP
-
Web 防护
http.request.bot.token
Object
客户端请求中包含的 Bot 校验票据信息。包括票据的详细状态:
status:票据是否有效
bot_client:客户端校验结果为 Bot 客户端
browser_client:客户端校验结果为浏览器客户端
-
Web 防护
http.request.ip.asn
String
与客户端 IP 地址相关联的 ASN
130340
Web 防护
http.request.xff_header_ip
String
客户端IP(优先匹配XFF头部)
93.184.216.34
Web 防护
http.request.bot.search_engine_bot_id
String
搜索引擎爬虫配置,用于处置来自搜索引擎爬虫的请求。此类请求的 IP、User-Agent 或 rDNS 结果匹配已知搜索引擎爬虫。
搜索引擎爬虫特征 ID
Web 防护
http.request.bot.known_bot_category_id
String
商业或开源工具 UA 特征配置(原 UA 特征规则),用于处置来自已知商业工具或开源工具的访问请求。此类请求的 User-Agent 头部符合已知商业或开源工具特征。
-
Web 防护
http.request.ip.source_idc_id
String
 客户端 IP 的来源 IDC 特征 ID。用于匹配来自 IDC(数据中心) 的客户端 IP 的访问请求。此类来源请求不是由移动端或浏览器端直接访问。
-
Web 防护
http.request.ip.reputation_id
String
 IP 威胁情报库特征 ID,用于匹配来自近期访问行为具有特定风险特征的客户端 IP 的请求。
-
Web 防护
http.request.bot.bot_rating_id
String
 智能 Bot 分析评级
-
Web 防护
http.request.bot.bot_intelligence_details
String
智能 Bot 分析对请求分析后,提取的爬虫风险详情
-
Web 防护