FAQ

Page Discussion History

Difference between revisions of "HttpAdditionModule"

m (References: Update link to the original documentation)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
__NOINDEX__
 +
 +
<span style="color:red">WARNING: this article is obsoleted. Please refer to http://nginx.org/en/docs/ for the latest official documentation.</span>
 +
 
<!-- page was renamed from NginxDocsEnglishDraftHttpAdditionModule
 
<!-- page was renamed from NginxDocsEnglishDraftHttpAdditionModule
 
-->
 
-->
Line 50: Line 54:
 
= Directives =
 
= Directives =
 
== add_before_body ==
 
== add_before_body ==
'''syntax:''' ''add_before_body uri''
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_addition_module/add_before_body.txt" />
 
+
'''default:''' ''no''
+
 
+
'''context:''' ''http, server, location''
+
  
 
Directive adds content of uri before the response body, issued as a result of the work of the assigned subrequest.  
 
Directive adds content of uri before the response body, issued as a result of the work of the assigned subrequest.  
  
 
== add_after_body ==
 
== add_after_body ==
'''syntax:''' ''add_after_body uri''
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_addition_module/add_after_body.txt" />
 
+
'''default:''' ''no''
+
 
+
'''context:''' ''http, server, location''
+
  
 
Directive adds content of uri after the response body, issued as a result of the work of the assigned subrequest.
 
Directive adds content of uri after the response body, issued as a result of the work of the assigned subrequest.
  
 
== addition_types ==
 
== addition_types ==
'''syntax:''' ''addition_types mime-type [mime-type ...]''
+
<include wikitext nopre src="http://wiki.nginx.org/nginx.org/http/ngx_http_addition_module/addition_types.txt" />
 
+
'''default:''' ''text/html''
+
 
+
'''context:''' ''http, server, location''
+
  
 
Directive (since 0.7.9) allows you to add text only to locations of the specified MIME-types (defaults to ''"text/html"'').  
 
Directive (since 0.7.9) allows you to add text only to locations of the specified MIME-types (defaults to ''"text/html"'').  

Latest revision as of 11:14, 10 April 2014


WARNING: this article is obsoleted. Please refer to http://nginx.org/en/docs/ for the latest official documentation.

Contents

Synopsis

This module adds contents of other locations before and after the current location's content.

It is implemented as an output filter, the contents of the main request and subrequests to other locations are not buffered completely and are still sent to the client in a streaming fashion. Because the length of the final response body is unknown while sending the HTTP headers, the HTTP chunked encoding is always used here.

Installation

By default the module is not built, it is necessary to enable its build with

./configure --with-http_addition_module

at compilation time.

Example:

location / {
  add_before_body   /before_action;
  add_after_body    /after_action;
}

Limitations

Note that as of 0.8.17 no contents will be added if the current location is served as a subrequest itself. Consider the following example:

location /foo {
  add_before_body /bar;
}
 
location /bar {
  add_before_body  /baz;
}

Then accessing /foo won't get /baz inserted before the contents of the subrequest /bar.

Also note that at this time, only strings can be used in before/after body locations, not variables. So

location / {
  set $before_action /before_action;
  add_before_body $before_action;
}

will not work as expected (although the configuration file will still load properly).

Directives

add_before_body

Syntax: add_before_body uri
Default:
Context: http
server
location
Reference:add_before_body


Directive adds content of uri before the response body, issued as a result of the work of the assigned subrequest.

add_after_body

Syntax: add_after_body uri
Default:
Context: http
server
location
Reference:add_after_body


Directive adds content of uri after the response body, issued as a result of the work of the assigned subrequest.

addition_types

Syntax: addition_types mime-type ...
Default: text/html
Context: http
server
location
Appeared in: 0.7.9
Reference:addition_types


Directive (since 0.7.9) allows you to add text only to locations of the specified MIME-types (defaults to "text/html").

(Before 0.8.17, this directive was mispelled as "addtion_types" in the source. This bug has been fixed in 0.8.17.)

References

Original Documentation