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

What are the common log variables in nginx

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Nginx which commonly used log variables, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Nginx log format and recommended format of common log variables: log_format main'$remote_addr\ t$http_x_forwarded_for\ t [$time_local]\ t$remote_user\ t$request\ t$status\ t$body_bytes_sent\ t$request_time\ t "$http_referer"\ t "$http_user_agent"\ t$http_host\ t$upstream_addr\ t$upstream_status It can also be replaced with other convenient characters nginx log field description: the parameter value $query_string # in the $args # request is the same as the NAME value in the $args$arg_NAME # GET request $is_args # if there is a parameter in the request, the value is "?", otherwise it is the empty string $uri # the current URI in the request (without the request parameter, the parameter is at $args), which can be different from the value of $request_uri passed by the browser, which can be redirected internally Or use the index directive to modify $uri without a hostname, such as "/ foo/bar.html". $document_uri # is the same as $uri$document_root # the currently requested document root or alias $host # priority: hostname of the HTTP request line > "HOST" request header field > server name that matches the request. The host header field in the request, if the host header in the request is not available, the server name that processes the request for the server $hostname # hostname $https # if SSL security mode is turned on, the value is "on", otherwise the empty string. The binary form of $binary_remote_addr # client address with a fixed length of 4 bytes $body_bytes_sent # the number of bytes transferred to the client, excluding the response header This variable is compatible with the "% B" parameter in Apache's mod_log_config module $bytes_sent # number of bytes transferred to the client $connection # TCP connection sequence number $connection_requests # TCP connection current number of requests $content_length # "Content-Length" request header field $content_type # "Content-Type" request header field $cookie_name # cookie name $limit_rate # used to set the response speed limit $msec # current Unix timestamp $nginx_version # nginx version $pid # PID$pipe # of the worker process if the request comes from a pipeline communication The value is "p", otherwise it is "." $proxy_protocol_addr # gets the client address of the proxy access server, or, in the case of direct access, the empty string $realpath_root # the real path to the currently requested document root or alias All symbolic connections are converted to the real path $remote_addr # client address $remote_port # client port $remote_user # user name for the HTTP basic authentication service $request # represents the client request address $request_body # client request body: this variable can be used in location to send the request subject through proxy_pass,fastcgi_pass Uwsgi_pass and scgi_pass are passed to the next level proxy server $request_body_file # to save 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 backend 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,or scgi_pass_request_body off$request_completion # if the request is successful, the value is "OK", or if the request is not completed or the request is not the last part of a scope request, it is empty $request_filename # the file path of the current connection request The length of the $request_length # request generated by the root or alias instruction and the URI request (including the address of the request, the http request header and the request body) $request_method # HTTP request method, usually the time taken by "GET" or "POST" $request_time # to process the client request, in seconds, precision milliseconds Starts from reading the first byte of the client until the last character is sent to the client for log writing. 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, such as the Web protocol used by "/ cnphp/test.php?arg=freemouse" $scheme # request, "http" or "https" $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 advance in the configuration file $server_name # server name $server_port # server port $server_protocol # server's HTTP version, usually "HTTP/1.0" or "HTTP/1.1" $status # HTTP response code $time_iso8601 # server time in ISO 8610 format $time_local # server time (LOG Format format) $cookie_NAME # client requests cookie variables in the header A variable with the prefix "$cookie_" and the cookie name, whose value is the value of the cookie name $http_NAME # matches any request header field The second half of the NAME in the variable name can be replaced with any request header field. For example, if you need to obtain the http request header in the configuration file: "Accept-Language", $http_accept_language can be used for $http_cookie$http_host # request address. That is, the address you enter in the browser (IP or domain name) $http_referer # url jump source, which is used to record the $http_user_agent # user terminal browser and other information accessed from that page link $http_x_forwarded_for$sent_http_NAME # you can set any http response header field The second half of the NAME in the variable name can be replaced with any response header field. If you need to set the response header Content-length,$sent_http_content_length, you can set the address of the upstream response time $upstream_addr background upstream during the sent_http_cache_control$sent_http_connection$sent_http_content_type$sent_http_keep_alive$sent_http_last_modified$sent_http_location$sent_http_transfer_encoding$upstream_response_time request. That is, the real service host address $upstream_status upstream status is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report