博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx的addition模块在响应的前后报文添加内容与变量的运行原理
阅读量:4677 次
发布时间:2019-06-09

本文共 2173 字,大约阅读时间需要 7 分钟。

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 makemv /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, locationSyntax: add_after_body uri;  # 在body之后添加Default: —Context: http, server, locationSyntax: 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.comWelcome to nginx!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.

For online documentation and support please refer tonginx.org.

Commercial support is available atnginx.com.

Thank you for using nginx.

  启用配置

[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.comnew centos before_actionWelcome to nginx!

Welcome to nginx!

If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.

For online documentation and support please refer tonginx.org.

Commercial support is available atnginx.com.

Thank you for using nginx.

new centos after_action

 

 
 

转载于:https://www.cnblogs.com/rdchenxi/p/11176953.html

你可能感兴趣的文章
【C语言】《C Primer Plus》递归:以二进制形式输出整数
查看>>
Ubuntu-proxy代理配置
查看>>
WordCountPro
查看>>
windbg入门
查看>>
OC-类目延展协议
查看>>
LSTM Accuracy
查看>>
$#,$?,$!等说明
查看>>
IOS应用
查看>>
教你用ps如何将图片、文字做出模糊斑驳的作旧效果
查看>>
推排序
查看>>
SPOOL、SQLLOADER数据导出导入的一点小总结
查看>>
js代码移动Div 移动平台与PC平台
查看>>
java学习——网络编程UDP
查看>>
leetcode 136 Single Number, 260 Single Number III
查看>>
WPF——RenderTransform特效
查看>>
使用框架的——好处
查看>>
如此大量的代码,但每个类里面的代码却不显得特别多,原因。。。。。。。。。。。。...
查看>>
C#特征备忘
查看>>
intelil——快捷键
查看>>
Java 面向对象 之 final 关键字
查看>>