Skip to content

conf module

paulran edited this page Apr 12, 2016 · 1 revision

config

include /path/to/configfile

ngx_module_t ngx_conf_module

static ngx_command_t  ngx_conf_commands[] = {

    { ngx_string("include"),
      NGX_ANY_CONF|NGX_CONF_TAKE1,
      ngx_conf_include,
      0,
      0,
      NULL },

      ngx_null_command
};


ngx_module_t  ngx_conf_module = {
    NGX_MODULE_V1,
    NULL,                                  /* module context */
    ngx_conf_commands,                     /* module directives */
    NGX_CONF_MODULE,                       /* module type */
    NULL,                                  /* init master */
    NULL,                                  /* init module */
    NULL,                                  /* init process */
    NULL,                                  /* init thread */
    NULL,                                  /* exit thread */
    ngx_conf_flush_files,                  /* exit process */
    NULL,                                  /* exit master */
    NGX_MODULE_V1_PADDING
};

Configuration file parsing process

main() -> ngx_init_cycle(old_cycle) -> ngx_conf_parse(cf, filename) -> ngx_conf_handler(cf, rc) -> cmd->set(cf, cmd, conf)
-> ngx_conf_parse(cf, NULL) -> ...

Recursive call ngx_conf_parse(cf, NULL):

    pcf = *cf;
    cf->ctx = ctx;
    cf->module_type = NGX_EVENT_MODULE;
    cf->cmd_type = NGX_EVENT_CONF;

    rv = ngx_conf_parse(cf, NULL);

    *cf = pcf;
Clone this wiki locally