Nginx 日志中记录cookie
2017-08-21 15:41
483 查看
因开发要求,在Nginx日志中需要记录Cookie信息,以便开发查询系统发生了什么,我的日志是以json格式显示,需要在nginx.conf文件中添加如下信息:
1,#vim nginx.conf
http {
include mime.types;
default_type application/octet-stream;
log_format logstash_json '{"@timestamp":"$time_iso8601",'
'"host":"$server_addr",'
'"clientip":"$remote_addr",'
'"size":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"url":"$uri",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
'"agent":"$http_user_agent",'
'"@req_body":"$request_body",'
'"$http_cookie":"$http_cookie",' 添加这行
'"status":"$status"}';
location ~* ^/test/.*$ {
proxy_hide_header Set-Cookie; 添加这行
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://10.9.54.1:797; 2,再查看Nginx日志,就可以显示Cookie信息了
1,#vim nginx.conf
http {
include mime.types;
default_type application/octet-stream;
log_format logstash_json '{"@timestamp":"$time_iso8601",'
'"host":"$server_addr",'
'"clientip":"$remote_addr",'
'"size":$body_bytes_sent,'
'"responsetime":$request_time,'
'"upstreamtime":"$upstream_response_time",'
'"upstreamhost":"$upstream_addr",'
'"http_host":"$host",'
'"url":"$uri",'
'"xff":"$http_x_forwarded_for",'
'"referer":"$http_referer",'
'"agent":"$http_user_agent",'
'"@req_body":"$request_body",'
'"$http_cookie":"$http_cookie",' 添加这行
'"status":"$status"}';
location ~* ^/test/.*$ {
proxy_hide_header Set-Cookie; 添加这行
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://10.9.54.1:797; 2,再查看Nginx日志,就可以显示Cookie信息了
相关文章推荐
- Nginx日志记录Cookie 学习笔记
- Nginx 日志中记录cookie
- nginx日志配置(cookie,header,post等字段记录)
- Nginx和Apache配置日志格式记录Cookie
- nginx日志切割和记录cookie
- Nginx配置日志格式记录cookie
- LNMP--Nginx不记录指定文件日志
- Nginx访问日志、Nginx日志切割、静态文件不记录日志和过期时间
- zabbix通过jmx监控tomcat, Nginx日志统计方案全过程,切割nginx和tomcat日志并删除指定天数前的日志记录
- Nginx不记录指定文件类型的日志
- Nginx反向代理Odoo后导致日志中Werkzeug记录的IP地址不正确的问题
- Nginx 指定不产生日志类型(不记录图片日志)
- 通过Nginx,Tomcat访问日志(access log)记录请求耗时
- Nginx访问日志、日志切割、静态文件不记录日志和过期时间
- nginx日志切割,日志格式,静态文件不记录日志,配置缓存
- Nginx访问日志、日志切割、静态文件不记录日志和过期时间
- nginx php-fpm记录php错误日志怎么配置
- Nginx 记录日志的几种方法
- LNMP - nginx不记录指定文件类型日志