Nginx学习笔记10HTTP访问日志
2021-07-05 12:07
标签:server real-ip favicon family span window user eve resource (1)access_log是ngx_http_log_module模块的配置项。 Syntax: access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]]; access_log off; Default: access_log logs/access.log combined; Context: http, server, location, if in location, limit_except Nginx的access_log和log_format配置项: log_format用于定义日志格式以及该格式的名称。 http下定义的log_format: log_format my_access_log $remote_addr,$remote_user,$time_local,$request,$status,$bytes_sent,$http_referer,$http_user_agent; http下定义的access_log,控制在无法匹配其它access_log条件的时候的访问日志: access_log logs/http_access.log my_access_log; location下定义的access_log,控制在URL包含/hello/路径时的访问日志: location ~ ^/hello/ { proxy_pass http://tomcat101.coe2coe.me:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; access_log logs/http_hello_access.log my_access_log; } 通过浏览器访问以下页面: http://ng.coe2coe.me:8000/hello/ http://ng.coe2coe.me:8000/hello/ http://ng.coe2coe.me:8000/hello/?a=1&b=2&c=3 http://ng.coe2coe.me:8000/abc/?a=1&b=2&c=3 产生的http_acess.log: 20.1.1.11,-,02/Jul/2017:10:57:37 +0800,GET /favicon.ico HTTP/1.1,200,1592,http://ng.coe2coe.me:8000/hello/,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 20.1.1.11,-,02/Jul/2017:11:12:05 +0800,GET /abc/?a=1&b=2&c=3 HTTP/1.1,403,726,-,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 产生的http_hello_access.log: 20.1.1.11,-,02/Jul/2017:10:57:37 +0800,GET /hello/ HTTP/1.1,200,3957,http://ng.coe2coe.me:8000/hello/,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 20.1.1.11,-,02/Jul/2017:10:57:37 +0800,GET /hello/resources/test.jpg HTTP/1.1,200,10277,http://ng.coe2coe.me:8000/hello/,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 20.1.1.11,-,02/Jul/2017:10:57:40 +0800,GET /hello/ HTTP/1.1,200,3852,http://ng.coe2coe.me:8000/hello/,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 20.1.1.11,-,02/Jul/2017:11:06:56 +0800,GET /hello/?a=1&b=2&c=3 HTTP/1.1,200,3757,-,Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 access_log相关的完整介绍,请参考: http://nginx.org/en/docs/http/ngx_http_log_module.html Nginx学习笔记10HTTP访问日志 标签:server real-ip favicon family span window user eve resource 原文地址:http://www.cnblogs.com/coe2coe/p/7106694.html
上一篇:js设计模式--单体模式
下一篇:HTML5中新增的元素
文章标题:Nginx学习笔记10HTTP访问日志
文章链接:http://soscw.com/index.php/essay/102060.html