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

Built-in variables

The following table describes the AScript 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. ngx.var.arg_{name}
Note Hyphens (-) in the {name} field must be replaced by underscores (_). For example, X-USER-ID must be changed to $arg_x_user_id.
$http_{name} The value of the name field in the request header. ngx.var.http_{name}
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. ngx.var.cookie_{name}
Note Hyphens (-) in the {name} field must be replaced by underscores (_). For example, X-USER-ID must be changed to $cookie_x_user_id.
$scheme The protocol type. ngx.var.scheme
$server_protocol The version of the protocol. ngx.var.server_protocol
$host The original host. ngx.var.host
$uri The original URI. ngx.var.raw_uri
$args $args represents all request parameters in an HTTP request, excluding question marks (?). For example, the URI of the request is http://www.a.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.
ngx.var.args
$request_method Indicates the request method. ngx.var.request_method
$request_uri The content of uri+'?'+args. ngx.var.request_uri
$remote_addr The IP address of the client that sends the request. ngx.var.remote_addr
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.