非常教程

Nginx参考手册

ngx_http_ssi_module

ngx_http_ssi_module

  • 示例配置
  • 指令
  • ssi
  • ssi_last_modified
  • ssi_min_file_chunk
  • ssi_silent_errors
  • ssi_types
  • ssi_value_length
  • SSI命令
  • 嵌入式变量

ngx_http_ssi_module模块是一个过滤器,用于处理通过它传递的响应中的SSI(服务器端包含)命令。目前,支持的SSI命令列表不完整。

示例配置

location / {
    ssi on;
    ...
}

指令

句法:

ssi 开启 | 关闭;

默认:

ssi 关闭;

语境:

http,服务器,位置,如果在指定位置

启用或禁用处理响应中的SSI命令。

句法:

ssi_last_modified 开启 | 关闭;

默认:

ssi_last_modified关闭;

语境:

http,服务器,位置

允许在SSI处理期间保留来自原始响应的“Last-Modified”标题字段以促进响应缓存。

默认情况下,由于响应的内容在处理期间被修改,因此标题字段被删除,并且可能包含动态生成的元素或部分,这些元素或部分独立于原始响应而被更改。

句法:

ssi_min_file_chunk大小;

默认:

ssi_min_file_chunk 1k;

语境:

http,服务器,位置

设置size存储在磁盘上的响应部分的最小值,从此开始使用sendfile发送它们是有意义的。

句法:

ssi_silent_errors开启|关闭;

默认:

ssi_silent_errors 关闭;

语境:

http,服务器,位置

如果启用,[an error occurred while processing the directive]如果在SSI处理过程中发生错误,则禁止输出“ ”字符串。

句法:

ssi_types mime-type ...;

默认:

ssi_types text / html;

语境:

http,服务器,位置

除了“ text/html” 之外,还可以在指定的MIME类型的响应中启用对SSI命令的处理。特殊值“ *”匹配任何MIME类型(0.8.29)。

句法:

ssi_value_length长度;

默认:

ssi_value_length 256;

语境:

http,服务器,位置

设置SSI命令中参数值的最大长度。

SSI命令

SSI命令具有以下通用格式:

<!--# command parameter1=value1 parameter2=value2 ... -->

支持以下命令:

block定义可以在include命令中用作存根的块。该块可以包含其他SSI命令。该命令具有以下参数:name块名称。例:

<!--# block name="one" -->
stub
<!--# endblock -->

config设置SSI处理期间使用的一些参数,即:errmsg如果在SSI处理过程中发生错误,则输出字符串。默认情况下,输出以下字符串:

[an error occurred while processing the directive]

timefmt传递给strftime()用于输出日期和时间的函数的格式字符串。默认情况下,使用以下格式:

"%A, %d-%b-%Y %H:%M:%S %Z"

%s”格式适合以秒为单位输出时间。echo输出变量的值。该命令具有以下参数:var变量名称。encoding编码方法。可能的值包括noneurl,和entity。默认情况下,使用entitydefault为一个非标准参数,用于设置在变量未定义时要输出的字符串。默认情况下,(none)输出“ ”。命令

<!--# echo var="name" default="no" -->

替换以下命令序列:

<!--# if expr="$name" --><!--# echo var="name" --><!--#
       else -->no<!--# endif -->

if执行有条件的包含。支持以下命令:

<!--# if expr="..." -->
...
<!--# elif expr="..." -->
...
<!--# else -->
...
<!--# endif -->

目前仅支持一种嵌套级别。该命令具有以下参数:expr表达式。一个表达式可以是:

  • 变量存在检查:<! - #if expr =“$ name” - >
  • 比较变量和文本:<! - #if expr =“$ name = _`text`_” - > <! - #if expr =“$ name!= _`text`_” - >
  • 使用正则表达式比较变量:<! - #if expr =“$ name = / _`text`_ /” - > <! - #if expr =“$ name!= / _`text` _ /“ - >

如果text包含变量,则它们的值将被替换。正则表达式可以包含稍后可以通过变量使用的位置和命名捕获,例如:

<!--# if expr="$name = /(.+)@(?P<domain>.+)/" -->
    <!--# echo var="1" -->
    <!--# echo var="domain" -->
<!--# endif -->

include将另一个请求的结果包含到响应中。该命令具有以下参数:file指定包含的文件,例如:

<!--# include file="footer.html" -->

virtual 指定一个包含的请求,例如:

<!--# include virtual="/remote/body.php?argument=value" -->

在一个页面上指定并由代理或FastCGI / uwsgi / SCGI服务器处理的多个请求并行运行。如果需要顺序处理,wait则应使用该参数。stub一个非标准参数,如果所包含的请求导致一个空体或在请求处理过程中发生错误,那么该参数将命名将输出内容的块,例如:

<!--# block name="one" -->&nbsp;<!--# endblock -->
<!--# include virtual="/remote/body.php?argument=value" stub="one" -->

替换块内容在包含的请求上下文中处理。wait一个非标准参数,指示在继续进行SSI处理之前等待请求完全完成,例如:

<!--# include virtual="/remote/body.php?argument=value" wait="yes" -->

set 指示将请求处理的成功结果写入指定变量的非标准参数,例如:

<!--# include virtual="/remote/body.php?argument=value" set="one" -->

应该注意的是,只有使用ngx_http_proxy_module,ngx_http_memcached_module,ngx_http_fastcgi_module(1.5.6),ngx_http_uwsgi_module(1.5.6)和ngx_http_scgi_module(1.5.6)模块获得的响应结果才能写入变量。set设置变量的值。该命令具有以下参数:var变量名称。value变量值。如果分配的值包含变量,则它们的值将被替换。

嵌入式变量

ngx_http_ssi_module模块支持两个嵌入式变量:

$date_local当地时区的当前时间。格式由config具有timefmt参数的命令设置。$date_gmt当前时间以GMT。格式由config具有timefmt参数的命令设置。

ngx_http_ssi_module
Nginx

Nginx是一款轻量级的 Web 服务器/反向代理服务器及电子邮件代理服务器,可在 BSD-like 协议下发行。其特点是占有内存少,并发能力强。

主页 https://nginx.org/
源码 http://hg.nginx.org/nginx
发布版本 1.13.6

Nginx目录

1.指南 | Guides
2.核心 | Core
3.ngx_google_perftools_module
4.ngx_http_access_module
5.ngx_http_addition_module
6.ngx_http_api_module
7.ngx_http_auth_basic_module
8.ngx_http_auth_jwt_module
9.ngx_http_auth_request_module
10.ngx_http_autoindex_module
11.ngx_http_browser_module
12.ngx_http_charset_module
13.ngx_http_core_module
14.ngx_http_dav_module
15.ngx_http_empty_gif_module
16.ngx_http_f4f_module
17.ngx_http_fastcgi_module
18.ngx_http_flv_module
19.ngx_http_geoip_module
20.ngx_http_geo_module
21.ngx_http_gunzip_module
22.ngx_http_gzip_module
23.ngx_http_gzip_static_module
24.ngx_http_headers_module
25.ngx_http_hls_module
26.ngx_http_image_filter_module
27.ngx_http_index_module
28.ngx_http_js_module
29.ngx_http_keyval_module
30.ngx_http_limit_conn_module
31.ngx_http_limit_req_module
32.ngx_http_log_module
33.ngx_http_map_module
34.ngx_http_memcached_module
35.ngx_http_mirror_module
36.ngx_http_mp4_module
37.ngx_http_perl_module
38.ngx_http_proxy_module
39.ngx_http_random_index_module
40.ngx_http_realip_module
41.ngx_http_referer_module
42.ngx_http_rewrite_module
43.ngx_http_scgi_module
44.ngx_http_secure_link_module
45.ngx_http_session_log_module
46.ngx_http_slice_module
47.ngx_http_spdy_module
48.ngx_http_split_clients_module
49.ngx_http_ssi_module
50.ngx_http_ssl_module
51.ngx_http_status_module
52.ngx_http_stub_status_module
53.ngx_http_sub_module
54.ngx_http_upstream_conf_module
55.ngx_http_upstream_hc_module
56.ngx_http_upstream_module
57.ngx_http_userid_module
58.ngx_http_uwsgi_module
59.ngx_http_v2_module
60.ngx_http_xslt_module
61.ngx_mail_auth_http_module
62.ngx_mail_core_module
63.ngx_mail_imap_module
64.ngx_mail_pop3_module
65.ngx_mail_proxy_module
66.ngx_mail_smtp_module
67.ngx_mail_ssl_module
68.ngx_stream_access_module
69.ngx_stream_core_module
70.ngx_stream_geoip_module
71.ngx_stream_geo_module
72.ngx_stream_js_module
73.ngx_stream_limit_conn_module
74.ngx_stream_log_module
75.ngx_stream_map_module
76.ngx_stream_proxy_module
77.ngx_stream_realip_module
78.ngx_stream_return_module
79.ngx_stream_split_clients_module
80.ngx_stream_ssl_module
81.ngx_stream_ssl_preread_module
82.ngx_stream_upstream_hc_module
83.ngx_stream_upstream_module