nginx log records the header information of the request

Reprinted:
Author: Sea Eagle
Address: http://blog.51yip.com/apachenginx/1277.html

 

Record the access log, in order to facilitate the inspection of the problem in case of special circumstances.

log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/51yip.log access;

Record, user ip, user real ip, user access time, browser information accessed by the user, etc. Where does this $remote_addr variable come from?

 

$arg_PARAMETER This variable contains the value of PARAMETER in the GET request in the query string.
The variable $args is equal to the arguments in the request line.
$binary_remote_addr Client address in binary form.
The Content-length field in the $body_bytes_sent
$content_length request header.
The Content-Type field in the $content_type request header.
$cookie_COOKIE The value of the cookie cookie.
$document_root currently requests the value specified in the root directive.
$document_uri is the same as $uri.
$host The host header field in the request, or the server name for the server to process the request if the host header in the request is not available.
$is_args Value "?" if $args is set, "" otherwise.
$limit_rate This variable can limit the connection rate.
$nginx_version The version number of nginx currently running.
$query_string is the same as $args.
$remote_addr The IP address of the client.
$remote_portThe port of the client.
$remote_user The username that has been authenticated by the Auth Basic Module.
$request_filename The file path of the current connection request, generated by the root or alias directive and the URI request.
The variable $request_body (0.7.58+) contains the main information of the request. Makes sense in locations using proxy_pass or fastcgi_pass directives.
$request_body_file Temporary file name for client request body information.
$request_completion request completion
$request_method This variable is the action requested by the client, usually GET or POST. Including 0.8.20 and earlier versions, this variable is always the action in the main request. If the current request is a sub-request, the action of the current request is not used.
The variable $request_uri is equal to the original URI containing some client request parameters, it cannot be modified, see $uri to change or rewrite the URI.
$schemeHTTP method (eg http, https). Use as needed, for example:
rewrite ^(.+)$ $scheme://example.com$1 redirect;

$server_addr server address, this value can be determined after completing 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 The server name.
$server_port The port number on which requests arrive at the server.
The protocol used by the $server_protocol request, usually HTTP/1.0 or HTTP/1.1.
The current URI in the $uri request (without request parameters, the parameters are located in $args), which can be different from the value of $request_uri passed by the browser, which can be modified by internal redirection, or by using the index directive.

The above are some built-in variables that nginx supports, of course we can customize, for example

$http_x_forwarded_for

This variable is custom and used to get the real IP of the proxy user.

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 

http://blog.csdn.net/adslcom/article/details/23714935

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326852946&siteId=291194637