nginx-----http配置的解析
2015-07-14 09:28
274 查看
对nginx配置解析这块,一直都是模模糊糊,没有条理,现在梳理一下:
1.nginx_core_module这个概念,在别人的文章中,经常出现经常混淆,它有两个意思:
1)一个意思就是nginx_core_module本身,它和nginx_http_module、nginx_event_module还有ngx_mail_module是并列的,他们是最上层的一些模块,你看他们的定义会发现,他们都是NGX_CORE_MODULE的,代码如下所示,这和nginx源码目录结构式一致的;另一个就是NGX_CORE_MODULE类型
ngx_module_t ngx_core_module = { NGX_MODULE_V1, &ngx_core_module_ctx, /* module context */ ngx_core_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING };
ngx_module_t ngx_events_module = { NGX_MODULE_V1, &ngx_events_module_ctx, /* module context */ ngx_events_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING };
ngx_module_t ngx_http_module = { NGX_MODULE_V1, &ngx_http_module_ctx, /* module context */ ngx_http_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING };
ngx_module_t ngx_mail_module = { NGX_MODULE_V1, &ngx_mail_module_ctx, /* module context */ ngx_mail_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ NULL, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ NULL, /* exit master */ NGX_MODULE_V1_PADDING };2) 上面几个核心模块的上下文都是ngx_core_module_t类型的,而他们这些核心模块内的子模块的上下文是不一样的,一会下面介绍;看了下面的代码,你会发现只有http模块、event模块等都是只有一个上下文的name;
typedef struct { ngx_str_t name; void *(*create_conf)(ngx_cycle_t *cycle); char *(*init_conf)(ngx_cycle_t *cycle, void *conf); } ngx_core_module_t;
static ngx_core_module_t ngx_events_module_ctx = { ngx_string("events"), NULL, ngx_event_init_conf };
static ngx_core_module_t ngx_core_module_ctx = { ngx_string("core"), ngx_core_module_create_conf, ngx_core_module_init_conf };
static ngx_core_module_t ngx_http_module_ctx = { ngx_string("http"), NULL, NULL };
<pre name="code" class="html">static ngx_core_module_t ngx_mail_module_ctx = { ngx_string("mail"), NULL, NULL };
相关文章推荐
- http错误代码表
- 网络处理1-异步GET请求
- IOS中http请求的cookie查看,删除,添加
- HttpClient4.x 使用cookie保持会话
- 关于SYN洪泛攻击简单介绍
- Unity5.1 新的网络引擎UNET(八) UNET 系统概括
- TCP连接的建立 (三次握手) 和释放 (四次握手)
- AJAX核心XMLHTTPRequest对象
- 网络拓扑发现工具
- HttpURLConnection根据URL下载图片
- HTTP请求方式
- HTTP 错误 500.21 - Internal Server Error
- XUtils HttpUtils 优化线程 防止无限访问网络
- HTTP 笔记与总结(5)socket 编程:使用 HTTP 协议模拟登录并发帖
- js测试网络连通情况
- Android 利用Fiddler进行网络数据抓包
- HTTPS那些事 用java实现HTTPS工作原理
- httpFS访问
- Linx监控分享--网络状态监控+邮件提醒
- 网络配置之ifconfig及Ip命令详解