学习了前面的一些代码,我们大概知道了Nginx的进程模型与事件处理模型,但是Nginx是著名的HTTP服务器,而我们目前好像并未学习到任何与HTTP相关的代码,那么Nginx究竟是怎么使用HTTP的各个模块的呢?
前面我们学习了Nginx的启动流程之ngx_init_cycle这个环节,而里面涉及到配置文件解析的内容,代码如下所示。从这个代码片段,我们可以发现: Nginx的配置文件解析是从NGX_CORE_MODULE类型的模块开始的。
conf.ctx = cycle->conf_ctx;
conf.cycle = cycle;
conf.pool = pool;
conf.log = log;
conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF;
if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
ngx_destroy_pool(pool);
return NULL;
}
&ngx_http_module,
&ngx_http_core_module,
&ngx_http_log_module,
&ngx_http_static_module,
&ngx_http_index_module,
&ngx_http_access_module,