Nginx

Nginx访问日志(access_log)配置及信息详解

2018-11-22  本文已影响0人  IARNO

通过访问日志,可以知晓用户的地址,网站的哪些部分最受欢迎,用户的浏览时间,对大多数用户用的的浏览器做出针对性优化。

Nginx中相关日志配置详解

image.png
#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

log_format参数:
       $remote_addr:访问网站的客户端地址
       $remote_user:客户端用户名
       $time_local:访问时间和时区
       $request:http行信息
       $status:状态码,如200,404等
       $body_bytes_sent :服务端发送给客户端的响应body字节数
       $http_referer:记录哪个链接访问过来的,可以根据参数进行防盗链设置
       $http_user_agent:客户端访问信息,如浏览器、手机客户端等
       $http_x_forwarded_for:当前端有代理服务器时,设置web节点记录客户端地址的配置,此参数生效的前提是代理服务器也要进行相关的x_forwarded_for设置

#access_log  logs/access.log  main;

access_log参数:
       logs/access.log:访问日志路径
       main:log_format中的main(日志格式名,可自定义)

详解 $http_x_forwarded_for

image.png
上一篇 下一篇

猜你喜欢

热点阅读