我们用的nginx有做过一些定制开发,为了调试方便,加了一些自定义的response header,那么如何把这个自定义头记录到日志中以便于观察呢?

  nginx log_format指令支持这种扩展,如下说明:

The headers, transmitted to client, begin from the prefix "sent_http_", for example, $sent_http_content_range.

Note that variables produced by other modules can also be logged. For example you can log upstream response headers with the prefix "upstream_http_", see upstream .

  wiki地址:http://wiki.nginx.org/HttpLogModule

  举例:如果你自定义的响应header是My_Custom_Header,那么只需要在log_format中增加$sent_http_my_custom_header即可

  PS:nginx对header的处理是大小写不敏感的。

nginx log_format指令记录自定义响应头的更多相关文章

  1. 浏览器获取自定义响应头response-headers

    原创作品版权归属本人所有,违者必究 https://blog.csdn.net/qq_37025445/article/details/82888731想在浏览器获取响应头里面自定义的响应头:file ...

  2. nginx自定义log_format以及输出自定义http头

    官方文档地址: http://nginx.org/en/docs/http/ngx_http_log_module.html 一.log_format默认格式 首先Nginx默认的log_format ...

  3. nginx反向代理proxy_set_header自定义header头无效

    公司使用nginx作为负载均衡,有时候需要自定义header头发送给后端的真实服务器. 想过去应该是非常的简单的事情. 例子如下: 设置代理服务器ip头   1 proxy_set_header X- ...

  4. Nginx配置各种响应头防止XSS,点击劫持,frame恶意攻击

    为什么要配置HTTP响应头? 不知道各位有没有被各类XSS攻击.点击劫持 (ClickJacking. frame 恶意引用等等方式骚扰过,百度联盟被封就有这些攻击的功劳在里面.为此一直都在搜寻相关防 ...

  5. nginx自定义模块记录上游服务器特定响应头

    功能,服务器通过扩展自定义命令,记录上游的服务器返回的特定响应头内容,记录到本地文件中 代码如下: /* * Copyright (C) Ciaos */ #include <ngx_confi ...

  6. nginx 定义:响应头和请求头

    1) 响应头 add_header 例如: add_header Cache-Control no-cache; add_header Access-Control-Allow-Origin *; a ...

  7. Nginx 操作响应头信息的实现

    前置条件:需要编译 ngx_http_headers_module 模块,才支持 header 头信息操作 add_header 意思为将自定义的头信息的添加到响应头,指令为 add_header n ...

  8. nginx替换响应头(重点:如何在替换时加上if判断)

    在实现微信小程序内嵌非业务域名时,通过nginx做镜像网站绕过小程序业务域名检测,但有一些表单页面提交后会返回一个302状态,由响应头Location的值决定提交成功后的跳转地址.那么问题来了,这个地 ...

  9. nginx 日志记录 自定义详解(分析上报用)

    nginx 日志记录 自定义详解   1.log_format 普通格式 log_format main '$remote_addr - $remote_user [$time_local] $req ...

随机推荐

  1. [转]struct实例字段的内存布局(Layout)和大小(Size)

    在C/C++中,struct类型中的成员的一旦声明,则实例中成员在内存中的布局(Layout)顺序就定下来了,即与成员声明的顺序相同,并且在默认情况下总是按照结构中占用空间最大的成员进行对齐(Alig ...

  2. oracle新建用户

    说明:以下命令在PLSQL中运行 一.以管理员身份登录PLSQL scott/root as sysdba 二.创建新用户 create user extjsTest1 identified by r ...

  3. C#学习笔记(一)

    1.cmd运行devenv启动VS. 2.解决方案:公司 项目:部门 类:员工 3.右边的解决方案管理器:会自动隐藏,想让他固定的话,就点击关闭按钮中间的“自动隐藏”:可以拖动到上下左右,当出现阴影的 ...

  4. uva 10810

    刘汝佳书上 143  归并排序求逆序数对 #include <cstdio> #include <cstring> #include <cstdlib> #incl ...

  5. 【leetcode】Combination Sum II (middle) ☆

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...

  6. Socat

    http://www.oschina.net/p/socat/ tcpick https://sourceforge.net/projects/tcpick/

  7. linux crontab任务调度的使用

    (不推荐)可以直接将要调度的任务写入crontab任务表中 (推   荐)可以先将要完成的任务写入一个shell文件,如myTask.sh(还可能需要将该文件改为可执行的:chmod 744 myTa ...

  8. cocos2d-x3.9 默认是 gnustl_static 配置,但是 这个库缺少c++的基础功能... c++_static 功能全面些

    最近的升级Cocos2d-x 3.2正式版.iOS不管是什么程序编译问题,使用结果cocos compile -p android编译APK计划.结果悲剧,出现以下错误. Android NDK: I ...

  9. QString和char字符数组之间的转换(QTextCodec.toUnicode方法,特别注意\0的问题)

    How can I convert a QString to char* and vice versa ?(trolltech) Answer:In order to convert a QStrin ...

  10. 每个QWidget都有contentsMargins函数,善用QMargins

    m_pSearchLineEdit = new QLineEdit(); QPushButton *pSearchButton = new QPushButton(this); pSearchButt ...