nginx built-in variables
Built-in variables are stored in the ngx_http_core_module module. The naming method of variables is consistent with the apache server variables. In summary, these variables represent the contents of client request headers, such as $http_user_agent, $http_cookie, etc. The following are all built-in variables supported by nginx:
$arg_name
The parameter name in the request, that is, the arg_name=arg_value form after "?"
$args
Parameter value in the request
$binary_remote_addr
The binary form of the client address, fixed length is 4 bytes
$body_bytes_sent
The number of bytes transmitted to the client, response Headers are not counted; this variable is compatible with the "%b" parameter in apache's mod_log_config module
$bytes_sent
The number of bytes transmitted to the client (1.3.8, 1.2.5)
$connection
The serial number of the tcp connection (1.3.8, 1.2.5)
$connection_requests
The current number of requests for the tcp connection (1.3.8, 1.2.5)
$content_length
"content-length" request header field
$content_type
"content-type" request header field
$cookie_name
cookie Name
$document_root
The document root directory or alias of the current request
$document_uri
Same as $uri
$host
The priority is as follows: http The host name of the request line>"host" request header field>matches the requested server name
$hostname
Host name
$http_name
matches any request header field; The second half of the variable name "name" can be replaced with any request header field. For example, if you need to obtain the http request header: "accept-language" in the configuration file, replace "-" with an underscore and uppercase letters with lowercase. The format is: $http_accept_language.
$https
If ssl security mode is enabled, the value is "on", otherwise it is an empty string.
$is_args
If there are parameters in the request, the value is "?", otherwise it is an empty string.
$limit_rate
is used to set the speed limit of the response, see limit_rate for details.
$msec
Current unix timestamp (1.3.9, 1.2.6)
$nginx_version
nginx version
$pid
Working The pid of the process
$pipe
If the request comes from pipe communication, the value is "p", otherwise it is "." (1.3.12, 1.2.7)
$proxy_protocol_addr
Get the client address of the proxy access server. If it is direct access, the value is an empty string. (1.5.12)
$query_string
Same as $args
$realpath_root
The real path of the currently requested document root or alias, will convert all symbolic links to real path.
$remote_addr
Client address
$remote_port
Client port
$remote_user
Username used for http basic authentication service
$request
Represents the client's request address
$request_body
The client's request body
This variable can be used in location to pass the request body through proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass passed to the next level proxy server.
$request_body_file
Save the client request body in a temporary file. After file processing is completed, this file needs to be deleted. If you need to enable this feature, you need to set client_body_in_file_only. If you pass the secondary file to the back-end proxy server, you need to disable the request body, that is, set proxy_pass_request_body off, fastcgi_pass_request_body off, uwsgi_pass_request_body off, or scgi_pass_request_body off.
$request_completion
The value is "ok" if the request is successful, or empty if the request is incomplete or the request is not the last part of a range request.
$request_filename
The file path of the current connection request, generated by the root or alias command and the uri request.
$request_length
The length of the request (including the requested address, http request header and request body) (1.3.12, 1.2.7)
$request_method
http request method , usually "get" or "post"
$request_time
The time used to process client requests (1.3.9, 1.2.6); starting from the first byte read from the client .
$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, does not contain the host name, for example: "/cnphp/test .php?arg=freemouse”.
$scheme
The web protocol used in the request, "http" or "https"
$sent_http_name
You can set any http response header field; the second half of the variable name "name" can be replaced with any response header field. If you need to set the response header content-length, replace "-" with an underscore and uppercase letters with lowercase letters, such as: $sent_http_content_length 4096.
$server_addr
Server-side address, it should be noted that in order to avoid accessing the Linux system kernel, the IP address should be set in the configuration file in advance.
$server_name
Server name, www.cnphp.info
$server_port
Server port
$server_protocol
The http version of the server, usually "http/1.0" or "http/1.1"
$status
http response code (1.3.2, 1.2.2)
$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $ tcpinfo_rcv_space
Detailed information of client tcp connection
$time_iso8601
Server time in iso 8610 format (1.3.12, 1.2.7)
$time_local
Server time (log format) (1.3.12, 1.2.7)
$uri
The current uri in the request (without request parameters, the parameters are located in $args), can be different from the value of $request_uri passed by the browser, it can be through internal redirection, or using index The command is modified so that $uri does not contain the host name, such as "/foo/bar.html".
nginx built-in global variables and their meaning
Name Version Description (the variable list comes from the file ngx_http_variables)
$args 1.0.8 Parameters in the request;
$binary_remote_addr 1.0.8 Binary representation of the remote address
$body_bytes_sent 1.0.8 Sent The number of bytes in the message body
$content_length 1.0.8 The "content-length";
$content_type in the http request information 1.0.8 The "content-type" in the request information;
$document_root 1.0. 8 Set the value for the root path of the current request;
$document_uri 1.0.8 The same as $uri; such as /test1/test2/test.php
$host 1.0.8 "host" in the request information, if the request If there is no host line, it is equal to the set server name;
$hostname 1.0.8
$http_cookie 1.0.8 Cookie information
$http_post 1.0.8 Reference address
$http_user_agent 1.0.8 Client agent information
$http_via 1.0.8 The last IP address to access the server.
$http_x_forwarded_for 1.0.8 Equivalent to the network access path.
$is_args 1.0.8
$limit_rate 1.0.8 Limitation on connection rate;
$nginx_version 1.0.8
$pid 1.0.8
$query_string 1.0.8 Same as $args ;
$realpath_root out ’ down ’ out down out out out out out off out out out way off out way’psy Inc’psypsypsypsypsycompatibility out way’psy’ way way way way way way way way way out way way way way out out way way way out out way way out way way way way way way rightpspspspspspsps outps out out out out out out out out out out out out out out’s together’s ’ ’ down off off down - - - and to the 1.0.8 Client username, used for authentication;
$request 1.0.8 User request
$request_body 1.0.8
$request_body_file 1.0.8 The name of the local file sent to the backend
$request_completion 1.0.8
$request_filename 1.0.8 Current Requested file path name, such as $request_filename: d:\nginx/html/test1/test2/test.php
$request_method 1.0.8 Requested method, such as "get", "post", etc.;
$ request_uri 1.0.8 The requested uri, with parameters; such as http://localhost:88/test1/test2/test.php
$scheme 1.0.8 The protocol used, such as http or https, such as rewrite^(. )$$scheme://example.com$1redirect;
$sent_http_cache_control 1.0.8
$sent_http_connection 1.0.8
$sent_http_content_length 1.0.8
$sent_http_content_type 1.0.8
$sent_http_keep_alive 1.0.8
$sent_http_last_modified 1.0.8
$sent_http_location 1.0.8
$sent_http_transfer_encoding 1.0.8
$server_addr 1.0.8 Server address, if you do not use listen to specify the server address, use this The variable will initiate a system call to get the address (causing waste of resources);
$ Server_name 1.0.8 Request server name;
$ Server_Port 1.0.8 The server -side number of the request; .8 The requested protocol version, "http/1.0" or "http/1.1";
$uri 1.0.8 The requested uri may be different from the original value, such as after redirection.
The above is the detailed content of What are the built-in variables of nginx?. For more information, please follow other related articles on the PHP Chinese website!

NGINX and Apache are both powerful web servers, each with unique advantages and disadvantages in terms of performance, scalability and efficiency. 1) NGINX performs well when handling static content and reverse proxying, suitable for high concurrency scenarios. 2) Apache performs better when processing dynamic content and is suitable for projects that require rich module support. The selection of a server should be decided based on project requirements and scenarios.

NGINX is suitable for handling high concurrent requests, while Apache is suitable for scenarios where complex configurations and functional extensions are required. 1.NGINX adopts an event-driven, non-blocking architecture, and is suitable for high concurrency environments. 2. Apache adopts process or thread model to provide a rich module ecosystem that is suitable for complex configuration needs.

NGINX can be used to improve website performance, security, and scalability. 1) As a reverse proxy and load balancer, NGINX can optimize back-end services and share traffic. 2) Through event-driven and asynchronous architecture, NGINX efficiently handles high concurrent connections. 3) Configuration files allow flexible definition of rules, such as static file service and load balancing. 4) Optimization suggestions include enabling Gzip compression, using cache and tuning the worker process.

NGINXUnit supports multiple programming languages and is implemented through modular design. 1. Loading language module: Load the corresponding module according to the configuration file. 2. Application startup: Execute application code when the calling language runs. 3. Request processing: forward the request to the application instance. 4. Response return: Return the processed response to the client.

NGINX and Apache have their own advantages and disadvantages and are suitable for different scenarios. 1.NGINX is suitable for high concurrency and low resource consumption scenarios. 2. Apache is suitable for scenarios where complex configurations and rich modules are required. By comparing their core features, performance differences, and best practices, you can help you choose the server software that best suits your needs.

Question: How to start Nginx? Answer: Install Nginx Startup Nginx Verification Nginx Is Nginx Started Explore other startup options Automatically start Nginx

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.

To shut down the Nginx service, follow these steps: Determine the installation type: Red Hat/CentOS (systemctl status nginx) or Debian/Ubuntu (service nginx status) Stop the service: Red Hat/CentOS (systemctl stop nginx) or Debian/Ubuntu (service nginx stop) Disable automatic startup (optional): Red Hat/CentOS (systemctl disabled nginx) or Debian/Ubuntu (syst


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool