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 variable | Description | NGINX 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 . |
| $scheme | The request scheme. | $scheme |
| $server_protocol | The protocol version. | $server_protocol |
| $host | The original host. | $host |
| $uri | The 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 .
| $args |
| $request_method | The request method. | $request_method |
| $request_uri | uri+'?'+argsThe original URI with query string arguments, which is equivalent to . | $request_uri |
| $remote_addr | The client IP address (the first IP address in the x-forwarded-for request header). | $remote_addr |
该文章对您有帮助吗?