Nginx variables | Common Nginx variables 

nginx

What is Nginx variables ?

Nginx variables are holding values within the Nginx configuration file.

Nginx offers two types of variables:

1. System Variables (Predefined Variables):

System variables defined by Nginx

Examples of system variables include `$http_host`, which holds the value of the “Host” header sent by the client, and `$request_uri`, which contains the original request URI.

System variables are accessible anywhere inside the config file.

2. User-Defined Variables:

Created by the administrator/Network Admin/ Devops etc.

They are prefixed with the ‘$’ symbol followed by a name

such as ‘$my_variable‘.// anythingh you can mention instead of my_variable

These variables can be used in different parts of the configuration file and can be used for different purposes

List of Nginx system variables 

VariableDescription
$argsThe arguments of the request as a query string
$request_uriThe original request URI, including the query string
$http_<header>The value of an HTTP request header, where <header> is the header name in lowercase, with hyphens replaced by underscores
$sent_http_<header>The value of an HTTP response header, where <header> is the header name in lowercase, with hyphens replaced by underscores
$query_stringThe query string portion of the request URI
$remote_addrThe IP address of the client making the request
$server_nameThe server name as specified in the server block
$request_methodThe HTTP request method (GET, POST, etc.)
$uriThe request URI without the query string
$document_rootThe root directory of the Nginx server
$hostnameThe hostname of the server (requires the ngx_http_core_module)
$server_portThe port number on which the server is listening
$ssl_protocolThe SSL/TLS protocol version used in the connection
$ssl_cipherThe SSL/TLS cipher suite used in the connection
$request_filenameThe file path being accessed by the request
$args_<name>The value of a query string parameter, where <name> is the parameter name
$cookie_<name>The value of a cookie, where <name> is the cookie name
$http_user_agentThe user agent string of the client making the request
$http_refererThe referer URL from which the request originated
$upstream_http_<header>The value of an HTTP response header from an upstream server, where <header> is the header name in lowercase, with hyphens replaced by underscores

These are just a few examples of the many variables available in Nginx.

Leave a Reply

Your email address will not be published. Required fields are marked *

web_horizontal
About Us Disclaimer Privacy Policy Terms & Conditions Contact Us

Copyright © 2023 ResearchThinker.com. All rights reserved.