alibaba/tengine
Tengine
Tengine उस साइट का HTTP देता है जिसे आप चलाते हैं. रिपॉज़िटरी खोज शब्द reverse से मिली. यह पेज उसके मुख्य नोट्स से जोड़ता है.
Core functionality
Directives
force_exit
Syntax: force_exit exit_time;
Default: —
Context: main
force worker processes to exit after exit_time.
The force_exit support is not enabled by default. You should compile it explicitly:
./configure --with-force-exit
Note: Removed force_exit directive after the Tengine-2.3.0 version and use Nginx official worker_shutdown_timeout , detailed reference worker_shutdown_timeout
worker_processes
Syntax: worker_processes [num | auto]
Default: worker_processes auto
Context: main
Set the number of worker processes.
When set to 'auto', which is also the default behavior, Tengine will create the same number of worker processes as your CPUs.
master_env
Syntax: master_env variable[=value];
Default: -
Context: main
If use master_env directive to set NGX_DNS_RESOLVE_BACKUP_PATH environment variable and dns cache will be enabled.
When the dns server is unavailable, it's will use the last dns cache.
For example master_env NGX_DNS_RESOLVE_BACKUP_PATH=/home/tengine/worker/dnscache/path, the domain A record results will be saved to the file and path depends on NGX_DNS_RESOLVE_BACKUP_PATH.
worker_cpu_affinity
Syntax: worker_cpu_affinity [mask1 mask2 mask3 ... | auto | off]
Default: worker_cpu_affinity off
Context: main
Bind worker processes to the sets of CPUs.
When set to 'auto', Tengine will automatically bind each worker process to a specific CPU. If the number of worker processes is larger than the number of your CPUs, then the rest of worker processes will be bond in descendant order. For example, if there are 8 CPUs in your system:
-
When the process number set to 4, the binding bitmap will be:
10000000 01000000 00100000 00010000
-
When the process number set to 8, the binding bitmap will be:
10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001
-
When the process number set to 10, the binding bitmap will be:
10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 10000000 01000000
When set to 'off', Tengine will disable the CPU affinity.
request_time_cache
Syntax: request_time_cache [on | off]
Default: request_time_cache on
Context: http, server, location
When set to 'off', Tengine will get a more precise time on $request_time, $request_time_msec, $request_time_usec because it does not use time cache.
log_empty_request
Syntax: log_empty_request [on | off]
Default: log_empty_request on
Context: http, server, location
When you specify it 'off', Tengine will not record any access log when a client issues a connection without any data being sent.
By default, it's on. In the above case, it will print a 400 Bad Request message into the access log.
server_admin
Syntax: server_admin admin
Default: none
Context: http, server, location
Specify the administrator's information, which will appear in a default 4xx/5xx error response when 'server_info' is turned on.
server_info
Syntax: server_info on | off
Default: server_info on
Context: http, server, location
Show up the server information in a default 4xx/5xx error response. The URL accessed by the user, the hostname serving the request, and the time are included.
server_tag
Syntax: server_tag off | customized_tag
Default: none
Context: http, server, location
Specify the customized 'Server' header in the HTTP responses, for example, 'Apache/2.2.22', 'IIS 6.0', 'Lighttpd', etc. You could also suppress the 'Server' header by setting it to 'off'.
reuse_port
Syntax: reuse_port on | off
Default: reuse_port off
Context: events
turn on support for SO_REUSEPORT socket option. This option is supported since Linux 3.9.
Note:
Removed reuse_port directive after the Tengine-2.3.0 version and use the official reuseport of Nginx, detailed reference document.
server_name
Syntax: server_name name;
Default: —
Context: server
server_name used in Stream module makes Tengine have the ability to listen same ip:port in multiply server blocks and. The connection will be attached to a certain server block by SNI extension in TLS. That means server_name should be used with SSL offloading(using ssl after listen).
The server_name support in Stream module is not enabled by default. You should compile it explicitly:
./configure --with-stream_sni
Note:
This feature is experimental. We will deprecate this feature if there is any conflict with similar feature of nginx official.
ssl_sni_force
Syntax: ssl_sni_force on | off
Default: ssl_sni_force off
Context: stream, server
ssl_sni_force will determine whether the TLS handsheke is rejected or not if SNI is not matched with server name which we configure by server_name in Stream module.
Note:
Same note in server_name above.
Core functionality
指令
force_exit
Syntax: force_exit exit_time;
Default: —
Context: main
强制worker进程在接受到QUIT信号后 exit_time 时间退出。
force_exit功能默认没有编译开启。需要编译时开启:
./configure --with-force-exit
注意:Tengine-2.3.0 版本后废弃force_exit指令,使用Nginx官方worker_shutdown_timeout指令替代,详细文档
worker_processes
Syntax: worker_processes [num | auto]
Default: worker_processes auto
Context: core
为worker_processes增加参数auto。当设置成auto,tengine将自动启动与cpu数量相同的worker进程。
master_env
Syntax: master_env variable[=value];
Default: -
Context: core
当使用master_env指令设置NGX_DNS_RESOLVE_BACKUP_PATH环境变量后将会开启dns缓存容灾逻辑。即当dns服务器不可用时,使用上次dns缓存的A记录。
比如设置master_env NGX_DNS_RESOLVE_BACKUP_PATH=/home/tengine/worker/dnscache/path;将会把配置中的域名解析结果缓存到NGX_DNS_RESOLVE_BACKUP_PATH所设置的路径下。
worker_cpu_affinity
Syntax: worker_cpu_affinity [mask1 mask2 mask3 ... | auto | off ]
Default: worker_cpu_affinity off
Context: core
为worker_cpu_affinity增加参数auto和off。当设置成auto时,tengine将根据worker的数量自动配置cpu绑定位图。绑定的顺序是按CPU编号从大到小。
如果worker数量大于cpu数量,则剩余的worker进程将按照CPU编号从大到小的顺序从编号最大的CPU开始再次绑定。例如:某CPU有8核,
- worker数量是4,则自动配置的绑定位图是10000000, 01000000, 00100000, 00010000
- worker数量是8,则自动配置的绑定位图是10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001
- worker数量是10,则自动配置的绑定位图是10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001, 10000000, 01000000
当设置成off时,tengine不会进行cpu绑定。
worker_cpu_affinity的error log最多显示64个CPU的绑定情况。
msie_padding
Syntax: msie_padding [on | off]
Default: msie_padding off
Context: http, server, location
此指令关闭或开启MSIE浏览器的msie_padding特性,若启用选项,nginx会为response头部填满512字节,这样就阻止了相关浏览器会激活友好错误界面,因此不会隐藏更多的错误信息。Tengine中默认关闭此功能。
request_time_cache
Syntax: request_time_cache [on | off]
Default: request_time_cache on
Context: http, server, location
设置成'off'时,Tengine将不使用时间缓存,$request_time、$request_time_msec和$request_time_usec将会得到更精确的时间。
log_empty_request
Syntax: log_empty_request [on | off]
Default: log_empty_request on
Context: http, server, location
设置成'off'时,Tengine将不会记录没有发送任何数据的访问日志。默认情况下,Tengine会在访问日志里面记录一条400状态的日志。
server_admin
Syntax: server_admin admin
Default: none
Context: http, server, location
设置网站管理员信息,当打开server_info的时候,显示错误页面时会显示该信息。
server_info
Syntax: server_info on | off
Default: server_info on
Context: http, server, location
当打开server_info的时候,显示错误页面时会显示URL、服务器名称和出错时间。
server_tag
Syntax: server_tag off | customized_tag
Default: none
Context: http, server, location
自定义设置HTTP响应的server头,‘off’可以禁止返回server头。如果什么都不设置,就是返回默认Nginx的标识。
reuse_port
Syntax: reuse_port on | off
Default: reuse_port off
Context: events
当打开reuse_port的时候,支持SO_REUSEPORT套接字参数,Linux从3.9开始支持。
注意:Tengine-2.3.0 版本后废弃reuse_port指令,使用Nginx官方的reuseport。升级方法:将events配置块里面的reuse_port on|off 释掉,在对应的监听端口后面加reuseport参数、详细参考文档 。
server_name
Syntax: server_name name;
Default: —
Context: server
在Stream模块中,server_name 可以用来允许多个server块监听同一个ip:port。Tengine会根据TLS的SNI来决定请求连接匹配到哪个server块。这意味着,Stream模块的server_name必须用在SSL卸载的情况下(即listen指令后面有ssl这个参数)。
Stream模块中的server_name 默认是不开启的. 你需要这么显示的编译:
./configure --with-stream_sni
注意:
这个特性是实验性的。如果Nginx官方有类似的功能和该功能有冲突,那么改功能将被废弃。
ssl_sni_force
Syntax: ssl_sni_force on | off
Default: ssl_sni_force off
Context: stream, server
在Stream模块中,ssl_sni_force决定了如果TLS的SNI和配置的server_name不匹配,TLS握手是否被拒绝。
注意:
详见server_name的注意点.
https://github.com/alibaba/tengine · पुस्तकालय