nginx默认未编译此模块;让nginx编译启用此模块

./configure --prefix=/data/web --sbin-path=/usr/bin --user=nginx --group=nginx --with-http_stub_status_module --with-http_auth_request_module --with-http_sub_module --add-module=/root/nginx-http-concat --with-http_addition_module
make
mv /usr/bin/nginx{,.07.12.13.18}
cp objs/nginx /usr/bin/
addition指令介绍
Syntax: add_before_body uri; #在body之前添加,添加的内容就是后面的uri,让nginx去访问这个uri获取资源,根户请求返回的添加待body之前
Default: —
Context: http, server, location
Syntax: add_after_body uri; # 在body之后添加
Default: —
Context: http, server, location
Syntax: addition_types mime-type ...; #那些资源类型的请求可以使用
Default: addition_types text/html;
Context: http, server, location

  配置不启用时;配置

[root@python vhast]# cat addition.conf
server {
server_name addition.com;
access_log logs/addition.log main;
location / {
#add_before_body /before_action;
#add_after_body /after_action;
#addition_types *;
}
location /before_action {
return 200 'new centos before_action\n';
}
location /after_action {
return 200 'new centos after_action\n';
}
}

  测试

[root@python vhast]# curl addition.com
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>

  启用配置

[root@python vhast]# cat addition.conf
server {
server_name addition.com;
access_log logs/addition.log main;
location / {
add_before_body /before_action; 头部添加;这个uri返回的结果
add_after_body /after_action; 尾部添加;这个uri返回的结果
addition_types *;
}
location /before_action {
return 200 'new centos before_action\n';
}
location /after_action {
return 200 'new centos after_action\n';
}
}

  测试

[root@python vhast]# curl addition.com
new centos before_action
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
new centos after_action
 

nginx的addition模块在响应的前后报文添加内容与变量的运行原理的更多相关文章

  1. Nginx 的过滤模块是干啥用的?

    上一篇文章我写了 Nginx 的 11 个阶段,很多人都说太长了.这是出于文章完整性的考虑的,11 个阶段嘛,一次性说完就完事了.今天这篇文章比较短,看完没问题. 过滤模块的位置 之前我们介绍了 Ng ...

  2. Nginx HTTP 过滤addition模块(响应前后追加数据)

    --with-http_addition_module 需要编译进Nginx 其功能主要在响应前或响应后追加内容 add_before_body 指令 将处理给定子请求后返回的文本添加到响应正文之前 ...

  3. nginx利用limit模块设置IP并发防CC攻击

    nginx利用limit模块设置IP并发防CC攻击 分类: 系统2013-01-21 09:02 759人阅读 评论(0) 收藏 举报 来源:http://blog.xencdn.net/nginx- ...

  4. nginx源代码分析--模块分类

    ngx-modules Nginx 基本的模块大致能够分为四类: handler – 协同完毕client请求的处理.产生响应数据.比方模块, ngx_http_rewrite_module, ngx ...

  5. Nginx Http 过滤模块

    L69 执行顺序在content阶段后 log阶段前调用的 也就是处理完用户业务后 准备记录处理日志之前 我们可以到nginx http_model.c里查看 数组 执行顺序从下至上顺序执行 copy ...

  6. Nginx range filter模块数字错误漏洞修复 (Nginx平滑升级) 【转】

    对线上生产环境服务器进行漏洞扫描, 发现有两台前置机器存在Nginx range filter模块数字错误漏洞, 当使用nginx标准模块时,攻击者可以通过发送包含恶意构造range域的header ...

  7. Nginx range filter模块数字错误漏洞修复 (Nginx平滑升级)

    对线上生产环境服务器进行漏洞扫描, 发现有两台前置机器存在Nginx range filter模块数字错误漏洞, 当使用nginx标准模块时,攻击者可以通过发送包含恶意构造range域的header ...

  8. Nginx 安装 --编译模块参数

    公司空出来一些服务器,很久没有来练手了,于是便开始有了这篇博客,记录下过程. Nginx 这个不多说了,名声在外,人们喜爱使用这款软件,主要还是因为它的高并发特性,公司也在用效果还不错,也用了它的一些 ...

  9. Nginx开发HTTP模块入门

    Nginx开发HTTP模块入门 我们以一个最简单的Hello World模块为例,学习Nginx的模块编写.假设我们的模块在nginx配置文件中的指令名称为hello_world,那我们就可以在ngi ...

随机推荐

  1. jquery 复制

    Jq将字符串复制粘贴到剪贴板     第一种: 自己测试时 只适合于input 和textarea 但是针对于其他标签的复制就不能用了.代码如下: <!DOCTYPE html> < ...

  2. List 数据分批入库

    直接贴代码,主要运用 List<E> subList(int fromIndex, int toIndex); 把 List 分割 /** * 保存批价结果 * * @param pric ...

  3. 1 dev repo organize

    码云  注册 组织  创建 仓库  创建 Git版本管理工具 download from https://www.git-scm.com/download/ 克隆/下载 git clone https ...

  4. 那些年做过的ctf之加密篇(加强版)

    MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...

  5. Educational Codeforces Round 70 (Rated for Div. 2) 题解

    比赛链接:https://codeforc.es/contest/1202 A. You Are Given Two Binary Strings... 题意:给出两个二进制数\(f(x)\)和\(f ...

  6. 【转载】巴塞尔问题(Basel Problem)的多种解法

    如何计算 \(\displaystyle \zeta \left ( 2 \right )=\frac{1}{1^{2}}+\frac{1}{2^{2}}+\frac{1}{3^{2}}+\cdots ...

  7. 对象的上转型和下转型 (instanceof关键字)

    1.对象的上转型,就是多态的一种写法 格式:父类名称 对象名 = new 子类名称(): Animal animal = new Cat(); 含义:右侧创建一个子类对象,把它当作父类来使用 向上转型 ...

  8. C语言:计算并输出S=1+(1+2^0.5)+(1+2^0.5+3^0.5)...+(1+2^0.5+3^0.5+...+n^0.5)

    //计算并输出S=1+(1+2^0.5)+(1+2^0.5+3^0.5)...+(1+2^0.5+3^0.5+...+n^0.5) #include<math.h> #include< ...

  9. ASP.NET Core搭建多层网站架构【9.2-使用Castle.Core实现动态代理拦截器】

    2020/01/31, ASP.NET Core 3.1, VS2019, Autofac.Extras.DynamicProxy 4.5.0, Castle.Core.AsyncIntercepto ...

  10. Python - 关于属性访问的优先级,属性访问顺序,python attributel lookup,类和实例访问属性的顺序

    object.__getattribute__(self, name) 类中的数据描述符 object.__dict__.get(name) 自身属性字典 object.__class__.__dic ...