Nginx配置指令类型
1、NGX_DIRECT_CONF:
所有NGX_DIRECT_CONF都是和NGX_MAIN_CONF同时出现的。NGX_DIRECT_CONF表示,配置文件对应的结构已经创建。对应NGX_CORE_MODULE类型的模块,且模块ngx_modules[]->ctx(上下文环境)成员ngx_core_module_t的create_conf不为空。
Directive only in the main configuration file,例如已经提供的配置指令daemon,master_process等。
例如,对应配置usr root; create_conf不为空。
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
};
2、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为空。
Directive only in the main configuration level,例如 http、mail、events、error_log等。
例如,对应配置error_log /usr/local/sms/logs/cache.log debug; create_conf为空
static ngx_core_module_t ngx_errlog_module_ctx = {
ngx_string("errlog"),
NULL,
NULL
};
3、NGX_ANY_CONF:
Directive can be used in at any level / directive,即该配置指令可以出现在任意配置级别上。例如include mime.types