UDFScript变量说明 本文介绍UDFScript的内置变量。 相关说明 UDFScript脚本引擎提供一些内置的nginx变量给业务脚本使用,业务脚本通过ctyun.var("变量名")或者"ctyun.var.变量名"获取。 注意 由于全局task脚本是全局性的(不是请求相关的),所以在全局task脚本中不能使用变量。 变量介绍 变量名 变量说明 示例 arg参数名 url中的某个具体参数的值。 比如:请求为: http参数名 某个请求头xxx的值。 比如:请求为: H "test: hello" H "headacc: 222"。 调用ctyun.var("httptest")返回“hello”。 调用ctyun.var("httpheadacc") 返回“222”。 注意: 如果xxx有破折号,通过var调用时,用下划线代替。 cookiexxx 请求cookie头中的name值。 使用方式同上。 scheme 请求使用的Web协议,“http” 或 “https”。 ctyun.var("scheme") 返回http。 serverprotocol 服务器的HTTP版本,通常为 “HTTP/1.0” 或 “HTTP/1.1”。 ctyun.var("serverprotocol") 返回HTTP/1.1。 timeiso8601 服务器时间的ISO 8610格式。 ctyun.var("timeiso8601") 返回 20220714T11:13:56+08:00。 timelocal 服务器时间。 ctyun.var("timelocal") 返回14/Jul/2022:11:13:56 +0800。 timehttp 服务器时间的http表示法。 ctyun.var("timehttp") 返回 Thu, 14 Jul 2022 03:13:56 GMT。 host 客户端请求的域名。 ctyun.var("host") 返回ctyun.cn。 requesturi 用户原始请求url包括查询参数。 比如:客户端发送请求uri为: /%E4%BD%A0%E5%A5%BD?tt123。 ctyun.var("requesturi") 返回/%E4%BD%A0%E5%A5%BD?tt123。 uri requesturi变量中不带查询参数部分,且进行urldecode。 比如:客户端发送请求uri为: /%E4%BD%A0%E5%A5%BD?tt123。 ctyun.var("uri") 返回 /你好。 querystring 查询参数, requesturi的参数部分。 比如:请求uri为: /hello?tt123&t2%E4%BD%A0%E5%A5%BD。 ctyun.var("querystring") 返回 tt123&t2%E4%BD%A0%E5%A5%BD。 requestmethod HTTP请求方法,通常为"GET"或"POST"等。 ctyun.var("requestmethod") 返回GET。 remoteaddr 返回客户端ip。 ctyun.var("remoteaddr") 返回172.21.51.44。 remoteport 客户端端口号。 ctyun.var("remoteport") 返回38966。 serveraddr 服务端ip。 ctyun.var("serveraddr") 返回172.21.51.88。 serverport 服务端端口号。 ctyun.var("serverport") 返回80。 isargs 是否有请求参数。 ctyun.var.isargs 返回 "?"或者空字符串。 args 请求参数。 ctyun.var.args 返回 "a1&b2&c3"。