Nginx - 指令(Directive)

Nginx - 指令(Directive) 首页 / Nginx入门教程 / Nginx - 指令(Directive)

Nginx由受配置文件中定义的指令控制的模块组成。指令分为两部分:

  • 简单指令(Simple Directive)  - 简单指令由名称和参数组成,以空格分隔,并以分号(;)结尾。
  • 块指令(Block Directive)         - 块指令的结构与简单指令相似,但不是分号,而是以花括号({和})包围的一组附加指令结尾。如果块指令可以在括号内包含其他指令,则称为上下文。例如。Events,http,location和server。

放置在任何上下文外部的配置文件中的指令均被视为在main context中。 events http 指令位于main context中,服务器位于 http location中的server中。

让我们看看一些重要指令的列表:

指令 语法 默认 Context
absolute_redirect absolute_redirect on|off; absolute_redirect on; http,server,location
accept_mutex accept_mutex on |off; off Events
accept_mutex_delay accept_mutex_delay time; accept_mutex_delay 500ms; Events
access_log(ngx_http_log_module) access_log path [format[buffer = size] [gzip [= level]] [flush = time] [if = condition]]; access_log off; access_log logs/access.log combined; http,server,location
access_log(ngx_stream_log_module) access_log path format [buffer = size] [gzip [= level]] [flush = time] [if = condition]; access_log off; access_log off; stream,server
add_after_body add_before_body uri; - http,server,location
add_before_body add_before_body uri; - http,server,location
add_header add_header name value [always]; - http,server,location
add_trailer add_trailer name value [always]; - http,server,location
addition_types addition_types mime-type ...; addition_types text/html; http,server,location
aio aio on |off|threads[=pool]; aio off; http,server,location
aio_write aio_write on | off; aio_write off; http,server,location
alias alias path; - server
allow(ngx_http_access_module) allow address | CIDR | Unix: | all; - http,server,location,limit_except
allow(ngx_stream_access_module) allow address | CIDR | Unix: | all; - stream,server
ancient_browser ancient_browser string...; - http,server,location
ancient_browser_value ancient_browser_value string; ancient_browser_value 1; http,server,location
api api [write = on | off]; - location
auth_basic auth_basic string | off; auth_basic off; http,server,location,limit_except
auth_basic_user_file auth_basic_user_file file; - http,server,location,limit_except
auth_http auth_http URL; - mail,server
auth_http_header auth_http_header header value; - mail,server
auth_http_pass_client_cert auth_http_pass_client_cert on | off; auth_http_pass_client_cert off; mail,server
auth_http_timeout auth_http_timeout time auth_http_timeout 60s; mail,server
auth_jwt auth_jwt string [token = $variable] |off; auth_jwt off; http,server,location,limit_except
auth_jwt_claim_set auth_jwt_claim_set $variable name...; - http
auth_jwt_header_set auth_jwt_header_set $variable name...; - http
auth_jwt_key_file auth_jwt_key_file file; - http,server,location,limit_except
auth_jwt_key_request

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

TensorFlow快速入门与实战 -〔彭靖田〕

Flutter核心技术与实战 -〔陈航〕

Electron开发实战 -〔邓耀龙〕

Java业务开发常见错误100例 -〔朱晔〕

程序员的个人财富课 -〔王喆〕

大数据经典论文解读 -〔徐文浩〕

Web漏洞挖掘实战 -〔王昊天〕

手把手带你写一个MiniSpring -〔郭屹〕

零基础GPT应用入门课 -〔林健(键盘)〕

好记忆不如烂笔头。留下您的足迹吧 :)