nginx 文档地址及配置文件入门

nginx 文档 tengine.taobao.org/nginx_docs/cn/d...
nginx 三方模块
www.nginx.com/resources/wiki/modul...

配置文件由指令和指令块构成

指令

worker_processes  2; #work进程的数量

worker_processes 指令;2 参数。

你可以在『指令目录』中搜索
nginx 文档地址及配置文件
nginx 文档地址及配置文件

指令块

events {
    use epoll;
    worker_connections  1024; #每个work进程支持的最大连接数
}

当然也可以从『指令目录』中查找

nginx 文档地址及配置文件

指令块中可再包含指令快

http {
    include mime.types; 
    server {

    }
}

http 基本配置

nginx 文档地址及配置文件

指令的上下文(重点)

参照上图 http 基本配置 来说明每个指令/指令块应该放在什么位置(即上下文)
worker_processes

nginx 文档地址及配置文件

server
nginx 文档地址及配置文件

location

nginx 文档地址及配置文件

模块

nginx由多个耦合度极低的模块组成,除了官方公布的模块外,也造就了庞大之外的第三方模块。

nginx 文档地址及配置文件入门

例如限制访问频率模块 ngx_http_limit_req_module
官方示例:

http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
    ...
    server {
        ...
        location /search/ {
            limit_req zone=one burst=5;
        }

其他

内嵌变量

内嵌变量在 http 核心模块 ngx_http_core_module (core核心)

nginx 文档地址及配置文件入门

进入页面后,

nginx 文档地址及配置文件入门

nginx 文档地址及配置文件入门

内嵌变量中一定能找到几个日常比较熟悉的~

计量单位

文档首页,

nginx 文档地址及配置文件入门

nginx 文档地址及配置文件入门

未看过nginx文档的朋友,看完本篇文章,是不是对 nginx 配置文件有了大概的了解呢。

本作品采用《CC 协议》,转载必须注明作者和本文链接
welcome come back
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
94
粉丝
24
喜欢
156
收藏
346
排名:325
访问:2.9 万
私信
所有博文
社区赞助商