nginx配置项NGX_DIRECT_CONF,NGX_MAIN_CONF和NGX_ANY_CONF

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

转载于:https://my.oschina.net/u/2326611/blog/1505383

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值