Mastering Nginx

(Ron) #1
Chapter 7

[ 171 ]

Since text/html is the default value, this type doesn't need
to be added—it won't be overwritten by adding additional
MIME types to be transformed. This principle applies to all
MIME type specification directives in NGINX.

The following table summarizes these directives:


Table: HTTP sub module directives

Directive Explanation
sub_filter Sets the string to be matched without
regards to case and the string to be
substituted into that match. The substitution
string may contain variables.
sub_filter_once Setting to off will cause the match in
sub_filter to be made as many times
as the string is found.
sub_filter_types Lists the MIME types of a response
in addition to text/html in which
a substitution will be made. It may
be * to enable all MIME types.

The xslt module


The xslt module works as a filter to transform XML using XSLT stylesheets. It is not


compiled by default, so if you would like to make use of it, you will need to install
the libxml2 and libxslt libraries and enable compilation of the module by passing


--with-http_xslt_module to NGINX's configure script.


To use the xslt module, you define a DTD in which the character entities are declared.


You then specify one or more XSLT stylesheets and their corresponding parameters to
process the XML document:


location / {

xml_entities /usr/local/share/dtd/entities.dtd;

xsl_stylesheet /usr/local/share/xslt/style1.xslt;

xsl_stylesheet /usr/local/share/xslt/style2.xslt theme=blue;

}
Free download pdf