All Products
Search
Document Center

CDN:EdgeScript built-in variables

Last Updated:Jan 18, 2024

This topic describes EdgeScript built-in variables and the corresponding NGINX variables.

Note
  • The dollar sign ($) before a variable is used to specify that the variable is a built-in variable. You can remove the dollar sign based on your business requirements.

  • Do not assign values to built-in variables in the same way as parameters.

  • You can specify at most 200 global variables and an unlimited number of local variables in a script. To specify more than 200 global variables in a script, create a custom function and use the global variables as local variables in the function.

The following table describes the EdgeScript built-in variables.

Built-in variable

Description

NGINX variable

$arg_{name}

The value of the name parameter in the query string. The query string represents request parameters in an HTTP request.

$arg_

Note

If the {name} field contains a hyphen (-), req_uri_arg instead of $arg_ is used to extract the header value. If the request is http://example.com/1.jpg?example-demo=123, the header value is extracted based on req_uri_arg('example-demo').

$http_{name}

The value of the name field in the request header.

$http_

Note

Hyphens (-) in the {name} field must be replaced by underscores (_). For example, X-USER-ID must be changed to $http_x_user_id.

$cookie_{name}

The value of the name field in the request cookie header.

$cookie_

Note

If the {name} field contains a hyphen (-), req_cookie instead of $cookie_ is used to extract the header value. If the request is cookie:example-demo=123, the header value is extracted based on req_cookie('example-demo'.

$scheme

The protocol type.

$scheme

$server_protocol

The protocol version.

$server_protocol

$host

The original host.

$host

$uri

The original URI.

None

$args

$args represents all request parameters in an HTTP request, excluding question marks (?). In the request http://example.aliyundoc.com/1k.file?k1=v1&k2=v2:

  • $arg_k1 returns the value of the k1 parameter: v1.

  • $args is used to return the entire query string: k1=v1&k2=v2. Question marks (?) are excluded.

$args

$request_method

The request method.

$request_method

$request_uri

The content of uri+'?'+args.

$request_uri

$remote_addr

The IP address used by the client to connect to points of presence (POPs).

$remote_addr