nginx日志配置(cookie,header,post等字段记录)
如果你对nginx日志格式,有这样那样的要求。
那么就看一下说明吧。
$remote_addr The remote host $remote_user The authenticated user (if any) $time_local The time of the access $request The first line of the request $status The status of the request $body_bytes_sent The size of the server's response, in bytes $http_referer The referrer URL, taken from the request's headers $http_user_agent The user agent, taken from the request's headers
如果你想记录某个cookie或者header里面的值的话
$cookie_[COOKIE_NAME]
$http_[HEADER_NAME]
我们来看下面的测试配置:
http {include mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user $server_name [$time_local] "$request" ''$status $body_bytes_sent "$request_body" "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for" "clickpid=$cookie_clickpid" "clickaid=$cookie_clickaid"';access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 8080;server_name localhost;#charset koi8-r;access_log logs/host.access.log main;location ~ \.php$ { #这里会记录post数据access_log logs/post.log main;proxy_set_header Host $http_host;proxy_pass http://127.0.0.1; }location / { #这里不会记录post数据 root html;index index.html index.htm;}
The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass.
只有在用了proxy_pass或者fastcgi_pass标记的location{ }里面变量$request_body才会生效。
可参考:
http://www.cnblogs.com/meteorx/p/3188647.html
另外,还可以参考:
http://articles.slicehost.com/2010/8/27/customizing-nginx-web-logs
日志滚动,可以参考:
http://linux008.blog.51cto.com/2837805/555829/ 使用logrotate
或者手动写脚本crontab 来执行:
#!/bin/sh mv /usr/local/Cellar/nginx/1.6.2/logs/host.access.log /usr/local/Cellar/nginx/1.6.2/logs/host.access.log.2015.4.3 kill -USR1 `cat /usr/local/var/run/nginx.pid` sleep 1
这里mv需要自己判断是否存在重名文件。
转载于:https://www.cnblogs.com/zhangqingping/p/4390862.html
nginx日志配置(cookie,header,post等字段记录)相关推荐
- Nginx 日志配置
1.Nginx 日志介绍 Nginx 有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志, 所需日志模块 ngx_http_log_module 的支持,日志格式通过 log_for ...
- 九爷带你了解 nginx 日志配置指令详解
nginx日志配置指令详解 日志对于统计排错来说非常有利的. 本文总结了nginx日志相关的配置如 access_log.log_format.open_log_file_cache.log_not_ ...
- Nginx 日志配置实践
前言 Nginx日志对于统计.系统服务排错很有用. Nginx日志主要分为两种:access_log(访问日志)和error_log(错误日志).通过访问日志我们可以得到用户的IP地址.浏览器的信息, ...
- Nginx日志配置、错误界面配置、流量控制 第九天
目录 nginx日志配置 nginx日志介绍 access.log error.log open_log_file_cache rewrite.log nginx的日志轮转 nginx错误界面配置 n ...
- Nginx 日志配置、日志切割
Nginx 日志配置.日志切割 设置 access.log 语法 log_format自定义格式 设置error_log 语法 日志切割 前置文章:Nginx 的配置文件 nginx.conf Ngi ...
- 渗透测试技术分享——nginx日志配置
Nginx 日志配置 0x00 前言 日志使用用来进行数据统计.问题排错的重要手段.本文主要介绍 nginx 日志相关的配置如 access_log.log_format.log_not_found. ...
- 【Nginx 日志配置】【访问日志log_format】【错误日志error_log 指令】【Nginx的日志轮转】
文章目录 Nginx 日志配置 `log_format` 指令中常用的一些变量: 访问日志 案例 可以配置段:`http`, `stream`, `server`, `location`作用域. er ...
- 运维配置:Nginx日志配置详解
Nginx日志配置详解 前言 Nginx日志对于统计.系统服务排错很有用.Nginx日志主要分为两种:access_log(访问日志)和error_log(错误日志).通过访问日志我们可以得到用户的I ...
- Nginx 日志配置、日志切割、日志切割脚本
文章目录 前言 一.access_log 1.语法 2.基本用法 3.作用域 4.log_format 自定义日志格式 二.error_log 1.语法 2.基本用法 3.作用域 4.rewrite_ ...
最新文章
- excel python开发_Excel + Python = 威力无比
- html页面内容改变,但是网页内容不变
- 广度优先搜索求解迷宫问题
- LeetCode算法题8:递归和回溯1
- 第一个 Windows 应用程序
- zbb20180415 cs 1.6 half-life launcher已停止工作
- IIS的安全配置策略
- 分布式数据库clickhouse、tidb、palo对比
- nginx rwrite及增加不记录特定状态日志nginx模块
- 灵动标签内sql语句调用
- 孙子兵法全文(原文)
- 计算机桌面文字重影,电脑桌面图标有重影是什么问题?
- 安卓升级AndroidX手把手教程
- BZOJ 5109: [CodePlus 2017]大吉大利,晚上吃鸡! 最短路 拓扑 Dp
- CentOS7图形界面启动报错unable to connect to X server
- 服务器c盘有个inetpub文件夹,关于C盘中的inetpub文件夹在win10电脑中的删除处理方法...
- mysql主从延迟时间是多少_MySQL主从同步个般是多久的延迟?
- GNS3实验操作(三)
- 游戏编程十年总结(上)
- matlab视频工具箱下载,MATLAB robotics tools工具箱下载安装