ngx_http_ssi_module
This module provides a filter which processes Server-Side Includes (SSI) in the input. The list of the supported commands for SSI is currently incomplete.
Example
location / {
ssi on;
}
Directives
ssi
syntax: ssi [ on | off ]
default: ssi off
context: http, server, location, if in location
Enables SSI processing.
ssi_silent_errors
syntax: ssi_silent_errors [on|off]
default: ssi_silent_errors off
context: http, server, location
Doesn't output "[an error occurred while processing the directive]", if an error occurs while processing the SSI.
ssi_types
syntax: ssi_types mime-type [mime-type ...]
default: ssi_types text/html
context: http, server, location
Enables SSI processing for MIME-types in addition to "text/html" types.
ssi_value_length
syntax: ssi_value_length length
default: ssi_value_length 256
context: http, server, location
Defines the allowed length of values for parameters used in SSI.
SSI Commands
Instruction format is the following
<!--# command parameter1=value parameter2=value... -->
The supported SSI commands are listed below:
block — command describes the block, which can be used as a silencer in command include. Inside the block there can be commands SSI.
name — the name of the block. For example:
<!--# block name="one" --> the silencer <!--# endblock -->
config — assigns some parameters with working SSI.
errmsg — the line, which is derived with the error during the SSI processing. By default, this string is used: "[an error occurred while processing the directive]"
timefmt — the time formatting string, as used in strftime(3). By default, this string is used:
"%A, %d-%b-%Y %H:%M:%S %Z"To include time in seconds use the format "%s" as well.
echo - print a variable
var — the name of the variable
default - if the variable is empty, display this string. Defaults to "none". Example:
<!--# echo var="name" default="no" -->is the same as
<!--# if expr="$name" --><!--# echo var="name" --><!--# else -->no<!--# endif -->
if/elif/else/endif — conditionally include text or other directives. Usage:
<!--# if expr="..." --> ... <!--# elif expr="..." --> ... <!--# else --> ... <!--# endif -->Only one level of nesting is possible.expr — the expression to evaluate. It can be a variable:
<!--# if expr="$name" -->A string comparison:
<!--# if expr="$name = text" --> <!--# if expr="$name != text" -->Or a regex match:
<!--# if expr="$name = /text/" --> <!--# if expr="$name != /text/" -->Если в text встречаются переменные, то производится подстановка их значений.
include — include a document from another source.
file — include a file, e.g.
<!--# include file="footer.html" -->virtual — include a request, e.g.
<!--# include virtual="/remote/body.php?argument=value" -->Multiple requests will be issued in parallel. If you need them issued sequentially, use the "wait" option.stub — The name of the block to use as a default if the request is empty or returns an error.
<!--# block name="one" --> <!--# endblock --> <!--# include virtual="/remote/body.php?argument=value" stub="one" -->wait — when set to yes, the rest of the SSI will not be evaluated until the current request is finished. Example:
<!--# include virtual="/remote/body.php?argument=value" wait="yes" -->
set - assign a variable.
- var — the variable.
- value — its value. If it contains variable names, these will be evaluated.
Built-in variables
ngx_http_ssi_module supports two built-in variables:
$date_local - the current time in the local timezone. The config option "timefmt" controls the format.
$date_gmt - the current time in GMT. The config option "timefmt" controls the format.
