AScript is a programmable scripting feature for Application Load Balancer (ALB) that lets you configure forwarding rules beyond what the ALB console supports. This page lists all AScript built-in variables and their corresponding NGINX variables.
Built-in variables
Request parameters
| Built-in variable | Description | NGINX variable |
|---|---|---|
$arg_{name} | Value of the {name} parameter in the query string. Hyphens (-) in {name} must be replaced with underscores (_). For example, use $arg_x_user_id to read the X-USER-ID parameter. | ngx.var.arg_{name} |
$args | The full query string, excluding the leading ?. For example, for the URL http://www.a.com/1k.file?k1=v1&k2=v2, $args returns k1=v1&k2=v2. To read a single parameter, use $arg_{name} instead. | ngx.var.args |
Request headers and cookies
| Built-in variable | Description | NGINX variable |
|---|---|---|
$http_{name} | Value of the {name} field in the request header. Hyphens (-) in {name} must be replaced with underscores (_). For example, use $http_x_user_id to read the X-USER-ID header. | ngx.var.http_{name} |
$cookie_{name} | Value of the {name} field in the cookie header. Hyphens (-) in {name} must be replaced with underscores (_). For example, use $cookie_x_user_id to read the X-USER-ID cookie. | ngx.var.cookie_{name} |
Request line and URI
| Built-in variable | Description | NGINX variable |
|---|---|---|
$request_method | The HTTP method of the request. | ngx.var.request_method |
$request_uri | The full original request URI, including the query string — equivalent to $uri + "?" + $args. Use $request_uri when you need the complete URI with parameters; use $uri if you only need the path. | ngx.var.request_uri |
$uri | The original URI. | ngx.var.raw_uri |
$host | The original host. | ngx.var.host |
$scheme | The protocol type. | ngx.var.scheme |
$server_protocol | The version of the protocol. | ngx.var.server_protocol |
Client information
| Built-in variable | Description | NGINX variable |
|---|---|---|
$remote_addr | The IP address of the client sending the request. | ngx.var.remote_addr |
Usage notes
The dollar sign (
$) identifies a variable as a built-in variable. Remove it if your business logic requires the variable name without the prefix.Do not assign values to built-in variables in the same way as parameters.
A script supports at most 200 global variables. Local variables are unlimited. To use more than 200 global variables, define a custom function and declare the excess variables as local variables inside the function.