


Describe nginx's built-in variables in detail
The built-in variables that can be used in the nginx configuration file start with the dollar sign $, and some people call them global variables. Among them, the values of some predefined variables can be changed.
$arg_PARAMETER The value of this variable is: the value of the variable name PARAMETER parameter in the GET request.
$args This variable is equal to the parameters in the GET request. For example, foo=123&bar=blahblah;This variable can only be modified
$binary_remote_addr The client address in binary code form.
$body_bytes_sent The number of bytes of the transmitted page
$content_length The Content-length field in the request header.
$content_type Content-Type field in the request header.
$cookie_COOKIE The value of cookie COOKIE.
$document_root The value specified in the root directive is currently requested.
$document_uri is the same as $uri.
$host The host header (Host) field in the request. If the host header in the request is unavailable or empty, it is the name of the server that processes the request (the value of the server_name directive of the server that processes the request). Values are lowercase and do not include ports.
$hostname The machine name uses the value of the gethostname system call
$http_HEADER The content in the HTTP request header, HEADER is the content in the HTTP request converted to lowercase, - becomes _ (dash becomes Underscore), for example: $http_user_agent (value of Uaer-Agent), $http_referer...;
$sent_http_HEADER The content in the HTTP response header, HEADER is the content in the HTTP response, converted to lowercase, - becomes _ (dash changes to underscore), for example: $sent_http_cache_control, $sent_http_content_type...;
$is_args If $args is set, the value is "?", otherwise it is "".
$limit_rate This variable can limit the connection rate.
$nginx_version The currently running nginx version number.
$query_string is the same as $args.
$remote_addr The IP address of the client.
$remote_port The port of the client.
$remote_user Username that has been verified by Auth Basic Module.
$request_filename The file path of the current connection request, generated by the root or alias directive and URI request.
$request_body This variable (0.7.58+) contains the main information of the request. Makes sense in locations using proxy_pass or fastcgi_pass directives.
$request_body_file The temporary file name of the client request body information.
$request_completion Set to "OK" if the request is successful; set to empty if the request is not completed or is not the last part of a series of requests.
$request_method This variable is the action requested by the client, usually GET or POST.
Including versions 0.8.20 and earlier, this variable is always the action in the main request. If the current request is a subrequest, the action of the current request is not used.
$request_uri This variable is equal to the original URI containing some client request parameters. It cannot be modified. Please see $uri to change or rewrite the URI.
$scheme protocol used, such as http or https, such as rewrite ^(.+)$ $scheme://example.com$1 redirect;
$server_addr server address, after completion This value can be determined after a system call. If you want to bypass the system call, you must specify the address in listen and use the bind parameter.
$server_name Server name.
$server_port The port number where the request reaches the server.
$server_protocol The protocol used by the request, usually HTTP/1.0 or HTTP/1.1.
$uri The current URI in the request (without request parameters, the parameters are located in $args) is different from the value of $request_uri passed by the browser. It can be modified through internal redirection or using the index directive. Exclude protocol and hostname, for example /foo/bar.html
The above is the detailed content of Describe nginx's built-in variables in detail. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

To get Nginx to run Apache, you need to: 1. Install Nginx and Apache; 2. Configure the Nginx agent; 3. Start Nginx and Apache; 4. Test the configuration to ensure that you can see Apache content after accessing the domain name. In addition, you need to pay attention to other matters such as port number matching, virtual host configuration, and SSL/TLS settings.

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".
