nginx配置项NGX_DIRECT_CONF,NGX_MAIN_CONF和NGX_ANY_CONF

Nginx配置指令类型

一、NGX_DIRECT_CONF:

全部NGX_DIRECT_CONF都是和NGX_MAIN_CONF同时出现的。NGX_DIRECT_CONF表示,配置文件对应的结构已经建立。对应NGX_CORE_MODULE类型的模块,且模块ngx_modules[]->ctx(上下文环境)成员ngx_core_module_t的create_conf不为空。spa

Directive only in the main configuration file,例如已经提供的配置指令daemon,master_process等。debug

例如,对应配置usr root; create_conf不为空。code

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_core_module_ctx = {
    ngx_string("core"),
    ngx_core_module_create_conf,
    ngx_core_module_init_conf
};


二、NGX_MAIN_CONF:

绝大多数NGX_MAIN_CONF和NGX_DIRECT_CONF是同时出现的。对于单独出现的NGX_MAIN_CONF表示,配置文件对应的结构尚未建立。配置文件中main区域的指令,都具备这个类型。  对应NGX_CORE_MODULE类型的模块,且模块ngx_modules[]->ctx(上下文环境)成员ngx_core_module_tgx_core_module_t的create_conf为空。string

Directive only in the main configuration level,例如 http、mail、events、error_log等。it

例如,对应配置error_log   /usr/local/sms/logs/cache.log debug; create_conf为空io

static ngx_core_module_t  ngx_errlog_module_ctx = {
    ngx_string("errlog"),
    NULL,
    NULL
};

 

三、NGX_ANY_CONF:

Directive can be used in at any level / directive,即该配置指令能够出如今任意配置级别上。例如include mime.typesevent

相关文章
相关标签/搜索