Nginx中文文档-ngx_http_core_module(M-P)

本文档包含以下指令:max_ranges、merge_slashes、msie_padding、msie_refresh、open_file_cache、open_file_cache_errors、open_file_cache_min_uses、open_file_cache_valid、output_buffers、port_in_redirect、postpone_output

max_ranges

语法:max_ranges number;
默认:—
上下文:http, server, location
版本:1.1.2+

限制请求中byte-range的最大数值,超过该值的请求会忽略byte-range。默认不限制该值,如果该值为0,则完全禁用byte-range功能。

merge_slashes

语法:merge_slashes on | off
默认:merge_slashes on
上下文:http, server

开启或禁用URI中的多个“/”的合并功能。
注意,对于正确的匹配前缀和正则表达式location,合并功能使必要的。如果不进行合并,“//scripts/one.php”请求将不会匹配以下location:

location /scripts/ {
    ...
}

还有可能被处理为一个静态文件。所以应该把它转换为“/scripts/one.php”。
如果一个URI包含了base64编码的参数,将合并功能关闭是必要的,因为在base64中“/”是一个合法的字符。但是,为了安全性考虑,最好不要将这个配置关闭。
如果该指令定义在server层级,这个值只能应用在带default的server中。这个值同样应用于所有监听同一个IP和端口的虚拟主机。

msie_padding

语法:msie_padding on | off
默认:msie_padding on
上下文: http, server, location

启用或禁用注释填充功能。当返回码大于400时,对于IE浏览器,是否需要填充注释信息,以便返回的内容达到512字节。(译者注:IE对于错误的网页状态码的处理有两种情况,如果经过gzip后小于512个字节,IE会出现默认的错误提示页;如果超过512个字节,则可以显示我们自己定义的错误页的内容,如个性化的404提示页)

msie_refresh

语法:msie_refresh on | off
默认:msie_refresh off
上下文: http, server, location

为IE开启或者关闭用页面刷新取代页面重定向的功能。

open_file_cache

语法:open_file_cache off
open_file_cache max=N [inactive=time]
默认:open_file_cache off
上下文:http, server, location

配置一个缓存,可以存储:

  • 打开文件描述符,包括文件大小、修改时间
  • 目录的信息
  • 文件查找错误,如“找不到文件”、“无权限读取文件”

错误数据的缓存可以单独通过open_file_cache_errors指令开启。
该指令有以下参数:
max
设置缓存中元素的最多个数;当缓存满了的时候,会用LRU方式删除最近最少使用的元素。
inactive
定义了多长时间没有使用到的缓存就被清除,默认是60秒。
off
关闭缓存
例子:

open_file_cache          max=1000 inactive=20s;
open_file_cache_valid    30s;
open_file_cache_min_uses 2;
open_file_cache_errors   on;

open_file_cache_errors

语法:open_file_cache_errors on | off
默认:open_file_cache_errors off
上下文:http, server, location

开启或关闭文件查找错误缓存功能,该功能是open_file_cache定义的。

open_file_cache_min_uses

语法:open_file_cache_min_uses number
默认:open_file_cache_min_uses 1
上下文: http, server, location

设置在由open_file_cache指令的inactive参数配置的超时时间内, 文件应该被访问的最小number。如果访问次数大于等于此值,文件描述符会保留在缓存中,否则从缓存中删除。

open_file_cache_valid

语法:open_file_cache_valid time
默认:open_file_cache_valid 60s
上下文:http, server, location

设置open_file_cache指令中的元素检测的时间间隔。

output_buffers

语法:output_buffers number size
默认:output_buffers 2 32k
上下文:http, server, location

设置读取磁盘文件缓存的数量和大小。
在1.9.5版本之前,默认值为1 32k。

port_in_redirect

语法:port_in_redirect on | off
默认:port_in_redirect on
上下文:http, server, location

开启或关闭nginx发起重定向时指定端口。
重定向中首要主机名的使用由server_name_in_redirect指令控制。

postpone_output

语法:postpone_output size
默认:postpone_output 1460
上下文:http, server, location

如果可能,到客户端的数据将被推迟发送,直到nginx需要发送的数据至少有size字节。 设置为0将关闭推迟发送的功能。