nginx日志输出自定义header头字段
2015-12-02 20:08
776 查看
这段时间做了一个web的项目,要求在日志中输出自定义的http header字段token和have-deleted的值,
nginx版本为1.1.19,以下是具体的log配置:
像have-deleted这种带横线的字段,需要写成have_deleted,nginx会自动做处理的。
有一点需要注意:我的nginx版本是1.1.19!!!
我写这篇博客的时候,nginx最新版本是1.9.7,根据官方文档说明,要想打印自定义的header字段,需要在字段前加sent_http_,所以一定要注意nginx的版本!!
最后附上nginx1.9.7的文档: http://nginx.org/en/docs/http/ngx_http_log_module.html
本文出自 “linux相关” 博客,请务必保留此出处http://diadia.blog.51cto.com/5440926/1719016
nginx版本为1.1.19,以下是具体的log配置:
log_format main '$remote_addr - $remote_user [$time_local] $http_token $http_have_deleted "$request" ' '$status $request_time $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';通过配置可以看出,可在自定义header字段前加http_,即可将指定的自定义header字段打印到log中。
像have-deleted这种带横线的字段,需要写成have_deleted,nginx会自动做处理的。
有一点需要注意:我的nginx版本是1.1.19!!!
我写这篇博客的时候,nginx最新版本是1.9.7,根据官方文档说明,要想打印自定义的header字段,需要在字段前加sent_http_,所以一定要注意nginx的版本!!
最后附上nginx1.9.7的文档: http://nginx.org/en/docs/http/ngx_http_log_module.html
本文出自 “linux相关” 博客,请务必保留此出处http://diadia.blog.51cto.com/5440926/1719016
相关文章推荐
- php环境搭建-WNMP(Win7+NGINX+MYSQL+PHP)
- Nginx安装
- nginx实现手机wap版和电脑pc版网站访问选择
- Nginx 新特性reuseport
- nginx搭建流媒体服务器
- nginx搭建流媒体服务器
- thinkphp配置nginx伪静态并解决PATHINFO问题和fix_pathinfo漏洞
- nginx 虚拟主机+负载均衡
- nginx的高级配置(5)——访问控制
- PhpStudy切换到nginx服务器后页面无法打开
- Nginx的学习
- nginx的高级配置(4)——防盗链
- nginx nginx.conf配置说明
- 安装nginx
- Nginx安装及配置文件nginx.conf详解
- nginx软负载的搭建
- nginx + lua 资源防盗链
- nginx优化 突破十万并发
- Nginx请求处理
- nginx+uwsgi部署flask(新)