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