Nginx日志管理

以下是Nginx日志的一个server段的配置,其中的access_log便是标记Nginx日志目录,紧随其后的main是日志格式

 server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

从配置文件的还可以看到具体main日志格式的定义,当然 ,我们也可以自定义:

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

上面的main具体包含以下内容:

远程IP- 远程用户/用户时间 请求方法(如GET/POST) 请求体body长度 referer来源信息
http-user-agent用户代理/蜘蛛 ,被转发的请求的原始IP
http_x_forwarded_for:在经过代理时,代理把你的本来IP加在此头信息中,传输你的原始IP
posted @ 2017-06-14 21:01  林豆包的长颈鹿  阅读(171)  评论(0编辑  收藏  举报