EdgeScript built-in variables

更新时间:
复制 MD 格式

This topic describes the built-in variables in EdgeScript, including their meanings and corresponding NGINX variables.

Note
  • The dollar sign ($) is an optional prefix for built-in variables. The variable functions correctly without it.
  • Built-in variables are read-only.
  • Each EdgeScript rule supports up to 200 global variables, with no limit on local variables. To use more than 200 global variables, define a custom function and declare the additional variables locally.
The following table lists the built-in variables for EdgeScript.
Built-in variableDescriptionNGINX variable
$arg_{name}query stringnamequery stringThe value of the parameter in the .$arg_
Note {name}req_uri_arg$arg_http://example.com/1.jpg?example-demo=123req_uri_arg('example-demo')If contains a hyphen (-), use the function instead of the variable to retrieve the value. For example, for the request , use .
$http_{name}The value of the specified field in the request header.$http_
Note {name}X-USER-ID$http_x_user_idIf contains a hyphen (-), you must replace it with an underscore (_). For example, to access the header, use the variable .
$cookie_{name}The value of the specified cookie in the cookie header.$cookie_
Note {name}req_cookie$cookie_cookie:example-demo=123req_cookie('example-demo')If contains a hyphen (-), use the function instead of the variable to retrieve the value. For example, to get the value from , use .
$schemeThe request scheme.$scheme
$server_protocolThe protocol version.$server_protocol
$hostThe original host.$host
$uriThe original URI.None
$args$args?http://example.aliyundoc.com/1k.file?k1=v1&k2=v2The string of all request parameters in the HTTP request, excluding the leading question mark (). For example, consider the request .
  • $arg_k1v1 retrieves the value .
  • $argsk1=v1&k2=v2? retrieves the full parameter string, .
$args
$request_methodThe request method.$request_method
$request_uriuri+'?'+argsThe original URI with query string arguments, which is equivalent to .$request_uri
$remote_addrThe client IP address (the first IP address in the x-forwarded-for request header).$remote_addr