Built-In Variables
Built-in variables in API7 Enterprise are pre-defined variables that can be directly referenced in configurations. They are often used in plugin configurations, route matching, and log customization.
API7 Enterprise supports three types of built-in variables:
- NGINX Variables
- APISIX Variables
These variables are evaluated in a given order.
NGINX Variables
NGINX provides a set of variables that can be used to access various request-specific information.
Some commonly used variables include:
upstream_addr
remote_addr
request_uri
server_name
uri
http_user_agent
See the complete list of NGINX variables for more information.
APISIX Variables
In addition to NGINX variables, APISIX offers a variety of built-in variables:
Variable Name | Description |
---|---|
post_arg_* | HTTP POST form data when the content type is application/x-www-form-urlencoded . The asterisk is to be replaced with the actual name of the POST form data. |
arg_* | URL query string. The asterisk is to be replaced with the actual query parameter name. |
http_* | HTTP request header. The asterisk is to be replaced with the actual name of the header. |
cookie_* | Request cookie. The asterisk is to be replaced with the actual name of the cookie. |
balancer_ip | Upstream server IP. |
balancer_port | Upstream server port. |
consumer_name | Consumer username. |
consumer_group_id | Consumer group ID. |
graphql_name | GraphQL operation name. |
graphql_operation | GraphQL operation type. |
graphql_root_fields | GraphQL root fields. |
route_id | Route ID. |
route_name | Route name. |
service_id | Service ID. |
service_name | Service name. |
resp_body | HTTP response body. |
mqtt_client_id | Client ID in MQTT protocol. |
redis_cmd_line | Redis command. |
rpc_time | RPC request round-trip time. |
Evaluation Order
API7 Enterprise evaluates variables in the given order:
- APISIX Variables
- NGINX Variables
If a variable is successfully sourced in custom variables, API7 Enterprise will not continue to look in APISIX variables or NGINX variables.
In other words, custom variables will overwrite variables of the same names defined in APISIX variables or NGINX variables, to better meet requirements of your specific use cases.