$args
The $args variable contains the query string arguments of the request, excluding the '?' character. — NGINX Core (HTTP)
Description
In NGINX, the $args variable is used to retrieve the query string from the URL of the incoming request. It includes any parameters that are passed as part of the URL following the '?' character. For example, in a URL like 'http://example.com/page?name=John&age=30', the $args variable would return 'name=John&age=30'. The $args variable is automatically populated when NGINX processes an HTTP request, making it readily available in several contexts, including within the server or location blocks, as well as in directives that accept variables. It's important to note that if there are no arguments in the query string, the value of $args will be an empty string. Additionally, this variable should be used cautiously to avoid accidentally exposing sensitive information that might be included in the query string.
Config Example
location /search {
if ($args) {
set $search_query $args;
# Log or handle the search query
access_log /var/log/nginx/search.log;
}
}Subsystem
httpCacheable
NoContexts
http, server, location, ifRemember that $args includes all query parameters, so be careful with sensitive data.
If there are no query parameters, $args will return an empty string, not 'null'.
Properly decode any URL-encoded values before using them, as $args will include them encoded.