ngx_http_core_module模块.md

Directives

aio

Syntax: aio on | off | threads[=pool];
Default: aio off;
Context:    http, server, location
This directive appeared in version 0.8.11.

在FreeBSD和Linux上启用或禁用异步文件I / O(AIO)的使用。在Linux上,AIO可以从内核版本2.6.22开始使用。此外,有必要启用directio,否则读取将阻塞:

location /video/ {
    aio            on;
    directio       512;
    output_buffers 1 128k;
}

详细请参考

aio_write

Syntax: aio_write on | off;
Default:    aio_write off;
Context:    http, server, location
This directive appeared in version 1.9.13.

如果启用了aio,请指定是否用于写入文件。 目前,这仅在使用aio线程时有效,并且仅限于使用从代理服务器接收的数据编写临时文件。

alias

Syntax: alias path;
Default:    —
Context:    location

定义指定位置的替换。路径值可以包含变量,$document_root和$ realpath_root除外。如果在使用正则表达式定义的位置内使用别名,则此类正则表达式应包含捕获,并且别名应引用这些捕获。

chunked_transfer_encoding

Syntax: chunked_transfer_encoding on | off;
Default:    chunked_transfer_encoding on;
Context:    http, server, location

允许在HTTP / 1.1中禁用分块传输编码。

client_body_buffer_size

Syntax: client_body_buffer_size size;
Default:    client_body_buffer_size 8k|16k;
Context:    http, server, location

设置用于读取客户机请求报文body的缓冲区大小。 在请求主体大于缓冲区的情况下,整个主体或仅其部分被写入临时文件。 默认情况下,缓冲区大小等于两个内存页。 这在x86,其他32位平台和x86-64上是8K。 在其他64位平台上通常为16K。

client_body_in_file_only

Syntax: client_body_in_file_only on | clean | off;
Default:    client_body_in_file_only off;
Context:    http, server, location

确定nginx是否应将整个客户端请求正文保存到文件中。该指令可以在调试期间使用,或者在使用$ request_body_file变量或ngx_http_perl_module模块的$ r-> request_body_file方法时使用。
当设置为on时,临时文件不会在请求处理后删除。
值为clean将导致删除请求处理后剩余的临时文件。

client_body_in_single_buffer

Syntax: client_body_in_single_buffer on | off;
Default:    client_body_in_single_buffer off;
Context:    http, server, location

确定nginx是否应将整个客户端请求正文保存在单个缓冲区中。

client_body_temp_path

Syntax: client_body_temp_path path [level1 [level2 [level3]]];
Default:    client_body_temp_path client_body_temp;
Context:    http, server, location

定义用于存储保存客户端请求正文的临时文件的目录。 在指定的目录下最多可以使用三级子目录层次结构。

client_body_timeout

Syntax: client_body_timeout time;
Default:    client_body_timeout 60s;
Context:    http, server, location

定义读取客户端请求报文body的超时时间。 超时时间仅设置在两个连续读取操作之间的时间段,而不是用于传输整个请求体。 如果客户端在此时间内未发送任何内容,则会将408(请求超时)错误返回给客户端。

client_header_buffer_size

Syntax: client_header_buffer_size size;
Default:    client_header_buffer_size 1k;
Context:    http, server

设置读取客户端请求报文header的缓冲区大小。 对于大多数请求,1K字节的缓冲区就足够了。 但是,如果请求包括长Cookie,或来自WAP客户端,它可能不适合1K。 如果请求行或请求头字段不适合该缓冲区,则分配由large_client_header_buffers指令配置的较大缓冲区。

client_header_timeout

Syntax: client_header_timeout time;
Default:    client_header_timeout 60s;
Context:    http, server

定义读取客户端请求报文header的超时。 如果客户端在此时间内未传输整个头,则会向客户端返回408(请求超时)错误。

client_max_body_size

Syntax: client_max_body_size size;
Default:    client_max_body_size 1m;
Context:    http, server, location

设置在“Content-Length”请求头字段中指定的客户机请求报文body的最大允许大小。 如果请求中的大小超过配置的值,则会将413(请求实体过大)错误返回给客户端。 请注意,浏览器无法正确显示此错误。 将大小设置为0将禁用对客户机请求正文大小的检查。

connection_pool_size

Syntax: connection_pool_size size;
Default:    connection_pool_size 256|512;
Context:    http, server

允许精确调整每个连接的内存分配。 此指令对性能影响最小,通常不应使用。 默认情况下,大小在32位平台上等于256字节,在64位平台上等于512字节。
Notes:在1.9.8版之前,所有平台上的默认值为256。

default_type

Syntax: default_type mime-type;
Default:    default_type text/plain;
Context:    http, server, location

定义响应的默认MIME类型。 可以使用types伪指令来将文件扩展名映射到MIME类型。

directio

Syntax: directio size | off;
Default:    directio off;
Context:    http, server, location
This directive appeared in version 0.7.7.

读取大于或等于指定大小的文件时,允许使用O_DIRECT标志(FreeBSD,Linux),F_NOCACHE标志(Mac OS X)或directio()函数(Solaris)。 该指令自动禁用(0.7.15)给定请求的sendfile的使用。

directio_alignment

Syntax: directio_alignment size;
Default:    directio_alignment 512;
Context:    http, server, location
This directive appeared in version 0.8.11.

设置方向的对齐方式。 在大多数情况下,512字节的对齐就足够了。 但是,在Linux下使用ZFS时,需要将其增加到4K。

Syntax: disable_symlinks off;
        disable_symlinks on | if_not_owner [from=part];
Default:    disable_symlinks off;
Context:    http, server, location
This directive appeared in version 1.1.15.

确定打开文件时应该如何处理符号链接:

  • off:路径名中的符号链接是允许的,不检查。这是默认行为。

  • on:如果路径名的任何组件是符号链接,则拒绝对文件的访问。

  • if_not_owner:如果路径名的任何组件是符号链接,并且链接指向的链接和对象具有不同的所有者,则拒绝对文件的访问。

  • from=part:当检查符号链接(参数on和if_not_owner)时,通常会检查路径名的所有组件。通过另外指定from = part参数可以避免检查路径名的初始部分中的符号链接。在这种情况下,只从指定的初始部分后面的路径名组件检查符号链接。如果值不是选中的路径名的初始部分,则将检查整个路径名,如同完全未指定此参数一样。如果值与整个文件名匹配,则不检查符号链接。参数值可以包含变量。

Notes:在不支持打开仅用于搜索的目录的系统上,要使用这些参数,需要工作进程对要检查的所有目录具有读取权限。
Notes:当前在ngx_http_autoindex_module,ngx_http_random_index_module和ngx_http_dav_module模块忽略此指令。

error_page

Syntax: error_page code ... [=[response]] uri;
Default:    —
Context:    http, server, location, if in location

定义将针对指定错误显示的URI。 uri值可以包含变量。
详情参考

etag

Syntax: etag on | off;
Default:    etag on;
Context:    http, server, location
This directive appeared in version 1.3.3.

Enables or disables automatic generation of the “ETag” response header field for static resources.

启用或禁用自动生成的“ETag”响应报文header字段的静态资源。

http

Syntax: http { ... }
Default:    —
Context:    main

提供指定HTTP服务器伪指令的配置文件上下文。

if_modified_since

Syntax: if_modified_since off | exact | before;
Default:    if_modified_since exact;
Context:    http, server, location
This directive appeared in version 0.7.24.

指定如何将响应的修改时间与“If-Modified-Since”请求头字段中的时间进行比较:

  • off:忽略“If-Modified-Since”请求头字段(0.7.34);

  • exact:完全符合;

  • before:响应的修改时间小于或等于“If-Modified-Since”请求头字段中的时间。

ignore_invalid_headers

Syntax: ignore_invalid_headers on | off;
Default:    ignore_invalid_headers on;
Context:    http, server

控制是否应忽略具有无效名称的header字段。 有效名称由英文字母,数字,连字符以及可能的下划线组成(由underscores_in_headers指令控制)。
如果在服务器级别指定了伪指令,那么只有在服务器是默认值时才使用该值。 指定的值也适用于侦听相同地址和端口的所有虚拟服务器。

internal;

Syntax: internal;
Default:    —
Context:    location

指定给定位置只能用于内部请求。 * 对于外部请求,返回客户端错误404(找不到)。 内部要求如下:

  • 请求被error_page,index,random_index和try_files指令重定向;

  • 由来自上游服务器的“X-Accel-Redirect”响应头字段重定向的请求;

  • 由ngx_http_ssi_module模块的“include virtual”命令和ngx_http_addition_module模块伪指令形成的子请求;

  • 请求由rewrite指令更改。

例如:

error_page 404 /404.html;

location /404.html {
    internal;
}

Notes:每个请求的限制为10个内部重定向,以防止在不正确的配置中发生的请求处理周期。 如果达到此限制,则返回错误500(内部服务器错误)。 在这种情况下,可以在错误日志中看到“rewrite or internal redirection cycle”消息。

keepalive_disable

Syntax: keepalive_disable none | browser ...;
Default:    keepalive_disable msie6;
Context:    http, server, location

指明禁止为何种浏览器使用keepalive功能; 浏览器参数指定将影响哪些浏览器。设置成msie6则在收到POST请求时禁用与旧版本的MSIE的保持活动连接。设置成safari则禁用与Mac OS X和Mac OS X类操作系统上的Safari浏览器的保持连接。设置成none则启用与所有浏览器的保持活动连接。

keepalive_requests

Syntax: keepalive_requests number;
Default:    keepalive_requests 100;
Context:    http, server, location
This directive appeared in version 0.8.0.

在keepalived连接上所允许请求的最大资源数量;默认为100;在发出最大数量的请求后,将关闭连接。

keepalive_timeout

Syntax: keepalive_timeout timeout [header_timeout];
Default:    keepalive_timeout 75s;
Context:    http, server, location

第一个参数设定keepalive连接的超时时长;0表示禁止长连接;默认为75s;可选的第二个参数在“Keep-Alive:timeout = time”响应报文header字段中设置一个值。 两个参数可能不同。“Keep-Alive:timeout = time”头字段由Mozilla和Konqueror识别。 MSIE在大约60秒内关闭保持连接。

large_client_header_buffers

Syntax: large_client_header_buffers number size;
Default:    large_client_header_buffers 4 8k;
Context:    http, server

设置用于读取大型客户端请求报文header的缓冲区的最大数量和大小。 请求行不能超过一个缓冲区的大小,超过则会显示414(Request-URI Too Large)错误返回到客户端。 请求报文header字段也不能超过一个缓冲区的大小,超过则会显示400(Bad Request)错误返回到客户端。 缓冲区仅在需要时分配。 默认情况下,缓冲区大小等于8K字节。 如果在请求处理结束之后连接被转换到保持活动状态,则释放这些缓冲器。

limit_except

Syntax: limit_except method ... { ... }
Default:    —
Context:    location

对指定范围之外的其它的方法进行访问控制; 方法参数可以是以下之一:GET,HEAD,POST,PUT,DELETE,MKCOL,COPY,MOVE,OPTIONS,PROPFIND,PROPPATCH,LOCK,UNLOCK或PATCH。 允许GET方法也允许HEAD方法。 可以使用ngx_http_access_module和ngx_http_auth_basic_module模块伪指令限制对其他方法的访问。

limit_rate

Syntax: limit_rate rate;
Default:    limit_rate 0;
Context:    http, server, location, if in location

限制客户端每秒钟所能够传输的字节数,默认为0表示无限制; 速率以字节/秒指定。这是对每个请求设置限制,因此如果客户端同时打开两个连接,则总速率将是指定限制的两倍。
在根据一定条件限制费率的情况下,速率限制也可以在$ limit_rate变量中设置。
速率限制也可以在代理服务器响应的“X-Accel-Limit-Rate”报头字段中设置。 此功能可以使用proxy_ignore_headers,fastcgi_ignore_headers,uwsgi_ignore_headers和scgi_ignore_headers指令禁用。

limit_rate_after

Syntax: limit_rate_after size;
Default:    limit_rate_after 0;
Context:    http, server, location, if in location
This directive appeared in version 0.8.0.

Sets the initial amount after which the further transmission of a response to a client will be rate limited.

设置初始量,在此之后,对客户端的响应的进一步传输将受到速率限制。

lingering_close

Syntax: lingering_close off | on | always;
Default:    lingering_close on;
Context:    http, server, location
This directive appeared in versions 1.1.0 and 1.0.6.

控制nginx如何关闭客户端连接。

  • on:指示nginx在完全关闭连接之前等待和处理来自客户端的附加数据,但只有在启发式表明客户端可能正在发送更多数据时。

  • always:将导致nginx无条件地等待和处理其他客户端数据。

  • off:告诉nginx不要等待更多数据并立即关闭连接。 此行为中断协议,不应在正常情况下使用。

lingering_time

Syntax: lingering_time time;
Default:    lingering_time 30s;
Context:    http, server, location

当lingering_close生效时,此指令指定nginx将处理(读取和忽略)来自客户端的其他数据的最大时间。之后,连接将关闭,即使会有更多的数据。

lingering_timeout

Syntax: lingering_timeout time;
Default:    lingering_timeout 5s;
Context:    http, server, location

当lingering_close生效时,此指令指定更多客户端数据到达的最长等待时间。 如果在此期间没有接收到数据,则连接关闭。 否则,读取和忽略数据,并且nginx再次开始等待更多数据。 “wait-read-ignore”循环被重复,但不长于由lingering_time指令指定的周期。

listen

Syntax: listen address[:port] [default_server] [ssl] [http2 | spdy] 
        listen port [default_server] [ssl] [http2 | spdy]
Default:    
listen *:80 | *:8000;
Context:    server

设置IP的地址和端口,或者服务器将接受请求的UNIX域套接字的路径。 可以指定地址和端口,或仅指定地址或仅指定端口。 地址也可以是主机名,例如:

listen 127.0.0.1:8000;
listen 127.0.0.1;
listen 8000;
listen *:8000;
listen localhost:8000;

default_server:设置默认虚拟主机;用于基于IP地址,或使用了任意不能对应于任何一个server的name时所返回站点;
ssl:用于限制只能通过ssl连接提供服务;
spdy:SPDY protocol(speedy),在编译了spdy模块的情况下,用于支持SPDY协议;
详细参考

location

Syntax: location [ = | ~ | ~* | ^~ ] uri { ... }
        location @name { ... }
Default:    —
Context:    server, location

允许根据用户请求的URI来匹配定义的各location,匹配到时,此请求将被相应的location块中的配置所处理;简言之,即用于为需要用到专用配置的uri提供特定配置;

  • =:URI的精确匹配;

  • ~:做正则表达式匹配,区分字符大小写;

  • ~*:做正则表达式匹配,不区分字符大小写;

  • ^~:URI的左半部分匹配,不区分字符大小写;

匹配优先级:精确匹配=、^或~*、不带符号的URL;
详细参考

log_not_found

Syntax: log_not_found on | off;
Default:    log_not_found on;
Context:    http, server, location

启用或禁用将未找到的文件的错误记录到error_log中。

log_subrequest

Syntax: log_subrequest on | off;
Default:    log_subrequest off;
Context:    http, server, location

启用或禁用将子请求记录到access_log中。

max_ranges

Syntax: max_ranges number;
Default:    —
Context:    http, server, location
This directive appeared in version 1.1.2.

限制请求中允许的最大字节范围数。 超出限制的请求将被处理,如同没有指定字节范围。 默认情况下,范围的数量不受限制。 零值将完全禁用字节范围支持。

merge_slashes

Syntax: merge_slashes on | off;
Default:    merge_slashes on;
Context:    http, server

启用或禁用将URI中的两个或多个相邻斜杠压缩为单个斜杠。
请注意,压缩对于前缀字符串和正则表达式位置的正确匹配至关重要。 没有它,//scripts/one.php请求将不匹。并可能被处理为静态文件。 所以它被转换为“/scripts/one.php”。
如果URI包含base64编码的名称,则可能需要关闭压缩,因为base64在内部使用“/”字符。 然而,出于安全考虑,最好避免关闭压缩。
如果在服务器级别指定了伪指令,那么只有在服务器是默认值时才使用该值。 指定的值也适用于侦听相同地址和端口的所有虚拟服务器。

msie_padding

Syntax: msie_padding on | off;
Default:    msie_padding on;
Context:    http, server, location

启用或禁用为状态大于400的MSIE客户端的响应添加注释,将响应大小增加到512字节。

msie_refresh

Syntax: msie_refresh on | off;
Default:    msie_refresh off;
Context:    http, server, location

启用或禁用对MSIE客户端发出刷新而不是重定向。

open_file_cache

Syntax: open_file_cache off;
open_file_cache max=N [inactive=time];
Default:    open_file_cache off;
Context:    http, server, location

配置可以存储以下内容的缓存:
(1) 文件描述符、文件大小和最近一次的修改时间;
(2) 打开的目录的结构;
(3) 没有找到的或者没有权限操作的文件的相关信息;
Notes:错误的缓存应该由open_file_cache_errors指令单独启用。

该伪指令具有以下参数:

  • max:表示可缓存的最大条目上限;一旦达到上限,则会使用LRU算法从缓存中删除最近最少使用的缓存项;

  • inactive:在此处指定的时长内没有被访问过的缓存项是为非活动缓存项,因此直接删除;

  • off:禁用高速缓存。

open_file_cache_errors

Syntax: open_file_cache_errors on | off;
Default:    open_file_cache_errors off;
Context:    http, server, location

是否缓存找不到其路径的文件,或没有权限没有权限访问的文件相关信息;

open_file_cache_min_uses

Syntax: open_file_cache_min_uses number;
Default:    open_file_cache_min_uses 1;
Context:    http, server, location

设置由open_file_cache指令的inactive参数配置的时间段内文件访问的最小数量,这是文件描述符在高速缓存中保持打开所必需的。

open_file_cache_valid

Syntax: open_file_cache_valid time;
Default:    open_file_cache_valid 60s;
Context:    http, server, location

每隔多久检查一次缓存中缓存项的有效性;默认为60s;

output_buffers

Syntax: output_buffers number size;
Default:    output_buffers 2 32k;
Context:    http, server, location

设置用于从磁盘读取响应报文的缓冲区的数量和大小。
Notes:在1.9.5版之前,默认值为1 32k。

port_in_redirect

Syntax: port_in_redirect on | off;
Default:    port_in_redirect on;
Context:    http, server, location

启用或禁用在nginx发出的重定向中指定端口。
在重定向中使用主服务器名称由server_name_in_redirect伪指令控制。

postpone_output

Syntax: postpone_output size;
Default:    postpone_output 1460;
Context:    http, server, location

If possible, the transmission of client data will be postponed until nginx has at least size bytes of data to send. The zero value disables postponing data transmission.

如果可能,客户端数据的传输将被推迟,直到nginx具有至少大小字节的数据要发送。 零值禁止推迟数据传输。

read_ahead

Syntax: read_ahead size;
Default:    read_ahead 0;
Context:    http, server, location

设置使用文件时内核的预读取量。

recursive_error_pages

Syntax: recursive_error_pages on | off;
Default:    recursive_error_pages off;
Context:    http, server, location

启用或禁用使用error_page指令执行多个重定向。 这种重定向的数量有限。

request_pool_size

Syntax: request_pool_size size;
Default:    request_pool_size 4k;
Context:    http, server

允许精确调整每个请求的内存分配。 此指令对性能影响最小,通常不应使用。

reset_timedout_connection

Syntax: reset_timedout_connection on | off;
Default:    reset_timedout_connection off;
Context:    http, server, location

启用或禁用重置超时连接。 复位如下进行。 在关闭套接字之前,将对其设置SO_LINGER选项,其超时值为0.当套接字关闭时,TCP RST将发送到客户端,并释放此套接字占用的所有内存。 这有助于避免使已填充缓冲区的已关闭套接字长时间处于FIN_WAIT1状态。

应注意,超时keep-alive 连接正常应该关闭。

resolver

Syntax: resolver address ... [valid=time] [ipv6=on|off];
Default:    —
Context:    http, server, location

配置用于将上游服务器的名称解析的地址为名称服务器。
详细参考

resolver_timeout

Syntax: resolver_timeout time;
Default:    resolver_timeout 30s;
Context:    http, server, location

设置名称解析的超时时间。

root

Syntax: root path;
Default:    root html;
Context:    http, server, location, if in location

设置请求的根目录。路径值可以包含变量,$document_root和$ realpath_root除外。
只有通过向root指令的值添加一个URI,即可构建文件的路径。 如果必须修改URI,则应使用alias伪指令。

satisfy

Syntax: satisfy all | any;
Default:    satisfy all;
Context:    http, server, location

如果ngx_http_access_module,ngx_http_auth_basic_module,ngx_http_auth_request_module或ngx_http_auth_jwt_module模块的所有(all)或至少一个(any)允许访问,则允许访问。

send_lowat

Syntax: send_lowat size;
Default:    send_lowat 0;
Context:    http, server, location

如果指令设置为非零值,nginx将尝试通过使用kqueue方法的NOTE_LOWAT标志或SO_SNDLOWAT套接字选项来最小化客户端套接字上的发送操作数。 在这两种情况下都使用指定的大小。在Linux,Solaris和Windows上将忽略此指令。

send_timeout

Syntax: send_timeout time;
Default:    send_timeout 60s;
Context:    http, server, location

发送响应报文的超时时长,默认为60s; 超时仅在两个连续的写操作之间设置,而不是用于传输整个响应。 如果客户端在此时间内未收到任何内容,则连接将关闭。

sendfile

Syntax: sendfile on | off;
Default:    sendfile off;
Context:    http, server, location, if in location

启用或禁用sendfile()的使用。
从nginx 0.8.12和FreeBSD 5.2.1开始,aio可以用来为sendfile()预加载数据。
在此配置中,使用SF_NODISKIO标志调用sendfile(),这导致它不会在磁盘I / O上阻塞,而是报告数据不在内存中。 然后,nginx通过读取一个字节来启动异步数据加载。 在第一次读取时,FreeBSD内核将一个文件的前128个字节加载到内存中,虽然下一次读取将只加载16K块的数据。 这可以使用read_ahead指令更改。
Notes:在1.7.11之前,可以使用aio sendfile启用预加载。

sendfile_max_chunk

Syntax: sendfile_max_chunk size;
Default:    sendfile_max_chunk 0;
Context:    http, server, location

当设置为非零值时,限制可以在单个sendfile()调用中传输的数据量。 如果没有限制,一个快速连接可以完全占用工作进程。

server

Syntax: server { ... }
Default:    —
Context:    http

设置虚拟服务器的配置。

server_name

Syntax: server_name name ...;
Default:    server_name "";
Context:    server

设置虚拟服务器的名称。后可跟一个或多个主机名;名称还可以使用通配符和正则表达式(~);
(1) 首先做精确匹配;例如:www.example.com
(2) 左侧通配符;例如:*.example.com
(3) 右侧通配符,例如:www.example.*
(4) 正则表达式,例如:~^.*.example.com$
(5) default_server
详细参考

server_name_in_redirect

Syntax: server_name_in_redirect on | off;
Default:    server_name_in_redirect off;
Context:    http, server, location

启用或禁用在由nginx发出的重定向中使用由server_name伪指令指定的主服务器名称。 当禁用主服务器名称的使用时,将使用“Host”请求头字段中的名称。 如果此字段不存在,则使用服务器的IP地址。
重定向中的端口的使用由port_in_redirect指令控制。

server_names_hash_bucket_size

Syntax: server_names_hash_bucket_size size;
Default:    server_names_hash_bucket_size 32|64|128;
Context:    http

设置服务器名称散列表的存储bucket大小。 默认值取决于处理器缓存线的大小。 设置哈希表的详细信息在单独的文档中提供。

server_names_hash_max_size

Syntax: server_names_hash_max_size size;
Default:    server_names_hash_max_size 512;
Context:    http

设置服务器名称哈希表的最大大小。

server_tokens

Syntax: server_tokens on | off | string;
Default:    server_tokens on;
Context:    http, server, location

启用或禁用在错误消息和“Server”响应头字段中发出nginx版本。

tcp_nodelay

Syntax: tcp_nodelay on | off;
Default:    tcp_nodelay on;
Context:    http, server, location

对keepalive模式下的连接是否使用TCP_NODELAY选项;

tcp_nopush

Syntax: tcp_nopush on | off;
Default:    tcp_nopush off;
Context:    http, server, location

是否启用TCP_NOPUSH(FREEBSE)或TCP_CORK(Linux)选项;仅在sendfile为on时有用;

try_files

Syntax: try_files file ... uri;
        try_files file ... =code;
Default:    —
Context:    server, location

尝试查找第1至第N-1个文件,第一个即为返回给请求者的资源;若1至N-1文件都不存在,则跳转至最一个uri(必须不能匹配至当前location,而应该匹配至其它location,否则会导致死循环);
详细参考

types

Syntax: types { ... }
Default:    types {
            text/html  html;
            image/gif  gif;
            image/jpeg jpg;
        }
Context:    http, server, location

将文件扩展名映射到MIME类型的响应。 扩展名不区分大小写。几个扩展可以映射到一个类型,例如:

types {
    application/octet-stream bin exe dll;
    application/octet-stream deb;
    application/octet-stream dmg;
}

在conf / mime.types文件中,nginx分发了一个足够完整的映射表。
要使特定位置发出所有请求的“application/octet-stream”MIME类型,可以使用以下配置:

location /download/ {
    types        { }
    default_type application/octet-stream;
}

types_hash_bucket_size

Syntax: types_hash_bucket_size size;
Default:    types_hash_bucket_size 64;
Context:    http, server, location

设置类型哈希表的存储bucket大小。 设置哈希表的详细信息在单独的文档中提供。
Notes:在版本1.5.13之前,默认值取决于处理器的缓存线的大小。

types_hash_max_size

Syntax: types_hash_max_size size;
Default:    types_hash_max_size 1024;
Context:    http, server, location

设置类型哈希表的最大大小。

underscores_in_headers

Syntax: underscores_in_headers on | off;
Default:    underscores_in_headers off;
Context:    http, server

启用或禁用在客户端请求报文header字段中使用下划线。 当禁用下划线的使用时,其名称包含下划线的请求标题字段将被标记为无效,并受到ignore_invalid_headers指令的约束。
如果在服务器级别指定了伪指令,那么只有在服务器是默认值时才使用该值。 指定的值也适用于监听相同地址和端口的所有虚拟服务器。

variables_hash_bucket_size

Syntax: variables_hash_bucket_size size;
Default:    variables_hash_bucket_size 64;
Context:    http

设置变量哈希表的bucket大小。

variables_hash_max_size

Syntax: variables_hash_max_size size;
Default:    variables_hash_max_size 1024;
Context:    http

设置变量哈希表的最大大小。
Notes:在版本1.5.13之前,默认值为512。

原文地址:https://www.cnblogs.com/cuchadanfan/p/6206735.html