1.9-nginx log of specified file types is not logged

Source: Internet
Author: User

Nginx logging and formatting, configured in the master configuration file

Vim/usr/local/nginx/conf/nginx.conf

In this line

Log_format combined_realip ' $remote _addr $http _x_forwarded_for [$time _local] '

' $host ' $request _uri "$status"

' "$http _referer" "$http _user_agent";


Combined_realip is the name of the log and can be customized. such as: WYP

$remote _addr Remote IP

$http IP for _x_forwarded_for proxy

[$time _local] Time

$host Domain Name

$request _uri Access Address

$status Status Code


Because the log format is defined in the master configuration file, it needs to be reflected in the virtual host configuration,

Root/usr/local/discuz; Insert the following code:

Access_log/tmp/access.log Combined_realip;

Format of the path and name log of the access log


Next, test it with curl-x127.0.0.1:80 Www.llzdwyp.com/123-I.

Found Access.log log file in/tmp, display/123 no 404 Code Found

If you use curl-x127.0.0.1:80 Www.llzdwyp.com-I to test

Will find a lot of access logs, including JPG, PNG and so on, let's get rid of these unrelated logs

Specify the access log, or use the location of this statement, it is important to note that: Localtion is in order, such as

match the first, do not match, so we defined the user authentication to be placed in front, the specified file type log is placed behind , otherwise you can also log in to the central administration.

Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $

{

Access_log off;

}

In the log there are many/static/and/cache/directory-independent logs, you can also specify not to log. Write a line above

Insert below the code above:

Location ~ (static|cache)

{

Access_log off;

}

Note: Remember that location has a matching order, this case is admin.php, so the order does not matter.

1.9-nginx log of specified file types is not logged

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.