This topic describes the syntax, features, parameters, and return values of request logic functions. This topic also provides examples of these functions.
server_addr
Item | Description |
Syntax | server_addr() |
Description | server_addr is used to query the IP address of the server that receives the current request. |
Parameter | N/A |
Examples | |
Return values | The IP address of the server. Data type: string. |
server_port
Item | Description |
Syntax | server_port() |
Description | server_port is used to query the server port that receives the current request. |
Parameter | N/A |
Examples | |
Return values | The server port that receives the current request. Data type: numeric. |
client_addr
If NAT is configured, the IP address returned by client_addr may not be the real client IP address.
Item | Description |
Syntax | client_addr() |
Description | client_addr is used to query the client IP address. |
Parameter | N/A |
Examples | |
Return values | The client IP address. Data type: string. |
client_port
Item | Description |
Syntax | client_port() |
Description | client_port is used to query the client port. |
Parameter | N/A |
Examples | |
Return values | The client port. Data type: numeric. |
req_uri
Item | Description |
Syntax | req_uri([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_uri_basename
Item | Description |
Syntax | req_uri_basename([pattern]) |
Description |
Sample file names:
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_uri_ext
Item | Description |
Syntax | req_uri_ext([pattern]) |
Description |
Sample extensions:
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_uri_seg
Item | Description |
Syntax | req_uri_seg([idx]) |
Description |
|
Parameter | idx: specifies the start index. This parameter is optional. |
Examples | |
Return values | Data type: dictionary. The relevant paragraphs are included. Note When the function retrieves the paragraph from the returned dictionary based on the specified index, the function checks whether the paragraph is empty. In this example, the following values are returned: |
req_uri_arg
Item | Description |
Syntax | req_uri_arg(name, [pattern]) |
Description | This function queries the value of a specified parameter. If the pattern parameter is included in the request, the value of the specified parameter is compared with the match conditions. The following table describes the details of this function. |
Parameter |
|
Examples | |
Return values |
In this example, the following values are returned: |
req_uri_query_string
Item | Description |
Syntax | req_uri_query_string([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_scheme
Item | Description |
Syntax | req_scheme([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_method
Item | Description |
Syntax | req_method([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_host
Item | Description |
Syntax | req_host([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_user_agent
Item | Description |
Syntax | req_user_agent([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_referer
Item | Description |
Syntax | req_referer([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_cookie
Item | Description |
Syntax | req_cookie(name, [pattern]) |
Description | This function queries the value of a specified cookie. If the pattern parameter is included in the request, the value of the specified cookie is compared with the match conditions. The following table describes the details of this function. |
Parameter |
|
Examples | |
Return values |
In this example, the following values are returned: |
req_first_x_forwarded
Item | Description |
Syntax | req_first_x_forwarded([pattern]) |
Description |
|
Parameter | pattern: compared with the match conditions. The following match types are supported:
|
Examples | |
Return values |
In this example, the following values are returned: |
req_header
Item | Description |
Syntax | req_header(name, [pattern]) |
Description | This function queries the value of a specified request header. If the pattern parameter is included in the request, the value of the specified request header is compared with the match conditions. |
Parameter |
|
Examples | |
Return values |
In this example, the following values are returned: |