nginx配置文件

一、配置文件结构

1. 简单指令

由用空格分割的名称和参数组成,并以分号(;)结尾。

2. 块指令

块指令和简单指令具有相同的结构,但不是以分号结尾,而是以大括号包围的一组附加指令结束。

官方原文

nginx consists of modules which are controlled by directives specified in the configuration file. 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 (;). 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 }).

3. 上下文

块指令的大括号如果包含其他指令,则它被称为上下文。
常用上下文 events、http、server、location

If a block directive can have other directives inside braces, it is called a context (examples: events, http, server, and location).
Directives placed in the configuration file outside of any contexts are considered to be in the main context. The events and http directives reside in the main context, server in http, and location in server.

4. #注释

主要用来说明配置

二、单位时间

1. 容量符号缩写

k,K 千字节
m,M 兆字节
例如, “8k”, “1m” 代表字节数计量.

2. 时间符号缩写

ms 毫秒
s 秒
m 分钟
h 小时
d 日
w 周
M 一个月, 30天
y 年, 365 天

通常按照从最大到最小的顺序指定多个单位,并可以用空格分隔,可以将多个单位组合一个值中。例如, “1h 30m”,、”90m” 、”5400s”,这三个时间是相同的。
没有后缀的值,默认单位为秒。建议始终指定一个后缀。
有些时间间隔只能用秒这个单位。

三、参考文章

http://nginx.org/en/docs/beginners_guide.html
http://www.nginx.cn/nginxchscommandline

Previous Post

nginx哈希值

Next Post

nginx

Related Posts