Configuration and cutting of Nginx log files

Source: Internet
Author: User
The configuration of Nginx log files involves two commands related to splitting Nginx logs: 1. log_format is used to set the log format; 2. access_log is used to specify the storage path, format, and cache size of log files. 1. use the log_format command to set the log format syntax: log_formatname... the configuration of Nginx log files involves two commands related to splitting Nginx logs: 1. log_format is used to set the log format; 2. access_log is used to specify the storage path, format, and cache size of log files. 1. use the log_format command to set the log format syntax: log_format name format [format...] explanation: name: defines the format name format: defines the format style log_format. there is a default combined log format that does not need to be set. apache uses this 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/usr/local/webserver/logs/access. log access. assume that the Nginx server is used as the Web server. after the server load balancer device, squid, and Nginx discover the proxy, the real IP address of the client cannot be obtained. The reason is that after reverse proxy, the Web server cannot directly obtain the IP address of the client because the intermediate layer is added between the client and the Web server, the IP address obtained through the $ remote_addr variable is the IP address of the reverse proxy server. However, the reverse proxy server can add X-Forwarde-For information in the HTTP header of the forwarded request to record the original client IP address and the server address of the original client request: $ remote_addr and $ http_x_frowarded_for are used to record IP addresses; $1 $ remote_user is used to record remote client user names; $ time_local is used to record access time and time zone; $ request is used to record request URL and HTTP protocol; $ status is used to record the status. for example, 200 is successful and 404 $9 $ body_bytes_sent is not found to record the size of the file body sent to the client; $ http_referer: the page link from which the user logs the access. $ http_user_agent is used to record the client's browser information.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.