Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx built-in variables

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Today, when I was sorting out the rewrite rules of nginx, I found that I encountered a lot of judgments about the built-in variables of nginx, so I will review the built-in variables of nginx here.

All built-in variables supported by nginx:

The parameter name in the $arg_name request, namely "?" The parameter value in the subsequent arg_name$args request in arg_name=arg_value form is $binary_remote_addr client address in binary form, with a fixed length of 4 bytes $the number of bytes transmitted to the client by body_bytes_sent, excluding the response header This variable is compatible with the "% B" parameter in Apache's mod_log_config module (1.3.8,1.2.5) the number of bytes transferred from $bytes_sent to the client (1.3.8,1.2.5) $serial number of connectionTCP connections (1.3.8,1.2.5) $current number of requests for connection_requestsTCP connections (1.3.8) 1.2.5) $content_length "Content-Length" request header field $content_type "Content-Type" request header field $cookie_namecookie name $document_root document root or alias of the current request $document_uri is the same as $uri$host priority: hostname of the HTTP request line > "HOST" request header field > server name that matches the request $hostname hostname $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 get the http request header "Accept-Language" in the configuration file, replace "-" with an underscore and uppercase letters with lowercase, such as: $http_accept_language. $https if SSL safe mode is enabled, the value is "on", otherwise it is an empty string. Is_args if there is a parameter in the request, the value is "?", otherwise it is an empty string. $limit_rate is used to set the speed limit for responses. For more information, please see limit_rate. The current Unix timestamp of $msec (1.3.9,1.2.6) $nginx_versionnginx version $pid worker process PID$pipe if the request comes from pipeline communication, the value is "p", otherwise it is "." (1.3.12,1.2.7) $proxy_protocol_addr gets the client address of the proxy access server, if it is direct access, the value is an empty string. (1.5.12) the real path of $query_string to the document root or alias currently requested by $args$realpath_root converts all symbolic links to the real path. $remote_addr client address $remote_port client port $remote_user user name for HTTP basic authentication service $request represents the request address of the client $request body of the request_body client this variable can be used in location to pass the request body to the next level proxy server through proxy_pass, fastcgi_pass, uwsgi_pass, and scgi_pass. Request_body_file saves the client request body in a temporary file. After the file processing, this file needs to be deleted. If you need one of them to turn on this feature, you need to set up client_body_in_file_only. If you pass the secondary file to the back-end proxy server, you need to disable request body, that is, set proxy_pass_request_body off,fastcgi_pass_request_body off, uwsgi_pass_request_body off, and or scgi_pass_request_body off. Request_completion is "OK" if the request is successful, or empty if the request is not completed or is not the last part of a scope request. The file path of the current connection request for $request_filename, generated by the root or alias directive and the URI request. The length of the $request_length request (including the address of the request, the http request header, and the request body) (1.3.12,1.2.7) $request_methodHTTP request method, usually "GET" or "POST" $request_time processing time (1.3.9,1.2.6); timing starts from reading the first byte of the client. The variable $request_uri is equal to the original URI that contains some client request parameters. It cannot be modified. Please see $uri to change or rewrite the URI without the hostname, for example: "/ cnphp/test.php?arg=freemouse". For the Web protocol used in the $scheme request, "http" or "https" $sent_http_name can set any http response header field; the latter part of the variable name "name" can be replaced with any response header field. If you need to set the response header Content-length, replace the "-" with an underscore and the uppercase letters with lowercase, such as $sent_http_content_length 4096. Server_addr server-side address, it should be noted that in order to avoid accessing the linux kernel, the ip address should be set in advance in the configuration file. $server_name server name $server_port server port $HTTP version of the server_protocol server, usually "HTTP/1.0" or "HTTP/1.1" $statusHTTP response code (1.3.2,1.2.2) $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space client TCP connection details $time_iso8601 server time ISO 8610 format (1.3.12) 1.2.7) $time_local server time (LOG Format format) (1.3.12,1.2.7) the current URI in the $uri request (without request parameters) The parameter is located at $args), which can be different from the value of $request_uri passed by the browser, which can be redirected internally or modified using the index directive. $uri does not contain a hostname, such as "/ foo/bar.html".

Reference: http://www.cnblogs.com/raichen/p/5121262.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report