Is there a wait to get at a module's main conf inside the loc conf's init?

ptcell nginx-forum at
Thu Aug 17 06:34:20 UTC 2017

Maxim Dounin Wrote:

> Try ngx_http_conf_get_module_main_conf().
> (Doing so in the create_loc_conf callback is probably pointless 
> though, as main conf contents can be changed later.)
> -- 
> Maxim Dounin
> _______________________________________________
> nginx mailing list
> nginx at

On a related note, is there a way to get the my module's main/srv/loc conf_t
instances from the cycle instance passed to the worker process init callback
in my module?     I see my conf objects created and put into the ctx object
before the worker process init is called, so I think there there.

>From reading the code, I tried something like:

#define ngx_http_cycle_get_module_main_conf(cf, module)                     
    ((ngx_http_conf_ctx_t *)

/* declared as init process in ngx_module_t     */
static ngx_int_t ngx_my_init_worker_process(ngx_cycle_t *cycle) {
   ngx_http_my_module_conf_t   *main_conf;
   main_conf = ngx_http_cycle_get_module_main_conf(cycle, 

but that either just returned Nulls or crashed.   I suspect there's a
simpler way.

Thank you very much!

Posted at Nginx Forum:,275998,276080#msg-276080

More information about the nginx mailing list