nginx的addition模块在响应的前后报文添加内容与变量的运行原理
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/
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模块在响应的前后报文添加内容与变量的运行原理的更多相关文章
- Nginx 的过滤模块是干啥用的?
上一篇文章我写了 Nginx 的 11 个阶段,很多人都说太长了.这是出于文章完整性的考虑的,11 个阶段嘛,一次性说完就完事了.今天这篇文章比较短,看完没问题. 过滤模块的位置 之前我们介绍了 Ng ...
- Nginx HTTP 过滤addition模块(响应前后追加数据)
--with-http_addition_module 需要编译进Nginx 其功能主要在响应前或响应后追加内容 add_before_body 指令 将处理给定子请求后返回的文本添加到响应正文之前 ...
- nginx利用limit模块设置IP并发防CC攻击
nginx利用limit模块设置IP并发防CC攻击 分类: 系统2013-01-21 09:02 759人阅读 评论(0) 收藏 举报 来源:http://blog.xencdn.net/nginx- ...
- nginx源代码分析--模块分类
ngx-modules Nginx 基本的模块大致能够分为四类: handler – 协同完毕client请求的处理.产生响应数据.比方模块, ngx_http_rewrite_module, ngx ...
- Nginx Http 过滤模块
L69 执行顺序在content阶段后 log阶段前调用的 也就是处理完用户业务后 准备记录处理日志之前 我们可以到nginx http_model.c里查看 数组 执行顺序从下至上顺序执行 copy ...
- Nginx range filter模块数字错误漏洞修复 (Nginx平滑升级) 【转】
对线上生产环境服务器进行漏洞扫描, 发现有两台前置机器存在Nginx range filter模块数字错误漏洞, 当使用nginx标准模块时,攻击者可以通过发送包含恶意构造range域的header ...
- Nginx range filter模块数字错误漏洞修复 (Nginx平滑升级)
对线上生产环境服务器进行漏洞扫描, 发现有两台前置机器存在Nginx range filter模块数字错误漏洞, 当使用nginx标准模块时,攻击者可以通过发送包含恶意构造range域的header ...
- Nginx 安装 --编译模块参数
公司空出来一些服务器,很久没有来练手了,于是便开始有了这篇博客,记录下过程. Nginx 这个不多说了,名声在外,人们喜爱使用这款软件,主要还是因为它的高并发特性,公司也在用效果还不错,也用了它的一些 ...
- Nginx开发HTTP模块入门
Nginx开发HTTP模块入门 我们以一个最简单的Hello World模块为例,学习Nginx的模块编写.假设我们的模块在nginx配置文件中的指令名称为hello_world,那我们就可以在ngi ...
随机推荐
- 用Fiddler实现手机抓包
手机用fiddler抓包 电脑最好是笔记本,这样能和手机保持统一局域网内:其他不多说,直接说步骤了. 一.对PC(笔记本)参数进行配置 1. 配置fiddler允许监听到https(fiddle ...
- 「JSOI2015」非诚勿扰
「JSOI2015」非诚勿扰 传送门 我们首先考虑一名女性选中她列表里第 \(x\) 名男性的概率(假设她列表里共有 \(s\) 名男性): \[ P = p \times (1 - p) ^ {x ...
- Java最新面试问答整理
Q:JDK和JRE区别? JDK是整个JAVA的核心,包括了Java运行环境JRE,一堆Java工具和Java基 础的类库.通过JDK开发人员将源码文件(java文件)编译成字节码文件(class文 ...
- 安慰奶牛Cheering up the Cow
传送门 一次a就很开心 可以当作kruskal模板题(orz --------------------------------------------------------------------- ...
- UVa 400 Unix Is命令
简单题 #include <bits/stdc++.h> using namespace std; const int maxn=110; string s[maxn]; int main ...
- linux 系统 grep 命令 摘录过滤特定的行
1.grep ‘xxx’ filename enter 其中xxx为要搜索的字符串 ,即可检索到含有 xxx的行. 2.grep 'xxx' filename >newfilename ...
- 计算机二级-C语言-对标志位的巧妙使用。对二维数组数据进行处理。对文件进行数据输入。
//函数fun的功能是:计算形参x所指数组中平均值(规定所有数均为正数),将所指数组中大于平均值的数据移至数组的前部,小于等于的移至后部,平均值作为返回值,在主函数中输出平均值和后移的数据. //重难 ...
- Java日期时间API系列8-----Jdk8中java.time包中的新的日期时间API类的LocalDate源码分析
目录 0.前言 1.TemporalAccessor源码 2.Temporal源码 3.TemporalAdjuster源码 4.ChronoLocalDate源码 5.LocalDate源码 6.总 ...
- SpringBoot2.x过后static下的静态资源无法访问
@Configuration public class CorsConfig extends WebMvcConfigurationSupport {/** * 添加静态资源文件,外部可以直接访问地址 ...
- WinForm开发(2)——DataGridView控件(2)——C# dataGridview控件,怎么获取行数
dataGridView1.Rows.Count;//所有行数dataGridView1.RowCount;//可见行数