--with-http_addition_module 需要编译进Nginx
其功能主要在响应前或响应后追加内容
add_before_body 指令 将处理给定子请求后返回的文本添加到响应正文之前
Syntax:
**add_before_body** `_uri_`;
Default:
—
Context:
http
, server
, location
add_after_body 指令
Syntax:**add_after_body** `_uri_`;
Default:—
Context:http
, server
, location
addition_types 指令 指定处理的文本类型
Syntax:
**addition_types** `_mime-type_` ...;
Default:
addition_types text/html;
Context:
http
, server
, location
演示
location / {
add_before_body /before_action;
add_after_body /after_action;
addition_types *;
}
location /before_action {
return 200 "before \n ";
}
location /after_action {
return 200 "after \n";
}