官网链接:Beginner’s Guide
翻译部分:Configuration File’s Structure
# nginx consists of modules which are controlled by directives specified in the configuration file.
nginx由模块构成,这些模块由指令控制,指令定义在nginx配置文件中
# Directives are divided into simple directives and block directives.
指令划分为简单指令和块指令
# A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;
).
简单指令由名称和参数构成,名称和参数用空格分隔开,指令以;结束,如:
proxy_pass http://www.baidu.com;
# A block directive has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces ({
and }
).
块指令有着和简单指令一样的结构,不同的是,块指令不以;结束,它被一对括弧{}包围
# If a block directive can have other directives inside braces, it is called a context (examples: events, http, server, and location).
如果块指令{}里面有其他指令(例如:events,http,server,location),那么它叫做context
# Directives placed in the configuration file outside of any contexts are considered to be in the main context.
在配置文件中但不在任何context(即{})里面的指令被认为是在main context
# The events
and http
directives reside in the main
context, server
in http
, and location
in server
.
人话:
events {} #events指令在main context里
http { #http指令在main context里
server { #server指令在http context里
location #location指令在server context里
}
}
# The rest of a line after the #
sign is considered a comment.
一行中在#后面的部分是注释