Nginx http module putting config in NGX_MAIN_CONF

Maxim Dounin mdounin at mdounin.ru
Tue Mar 20 12:52:23 UTC 2012


Hello!

On Tue, Mar 20, 2012 at 05:23:47PM +0530, vivek goel wrote:

> hi,
> I want to put variable inside nginx NGX_MAIN_CONF
> 
> I want written code like this
> 
>  { ngx_string("mydata"),
>    NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
>    ngx_conf_set_str_slot,
>    0,
>    offsetof(ngx_http_my_main_conf_t, my_data),
>    NULL },
> 
> 
> But when I put in in configuration file
> worker_processes  2;
> mydata "a";
> 
> I am getting following error
> nginx: [emerg] unknown directive "mydata"
> 
> How to fix this ?

You can't define global directives from a http module.  Either use 
NGX_HTTP_MAIN_CONF instead (and the directive will be available in 
http{} section), or define a core module (with module type set 
to NGX_CORE_MODULE).

Maxim Dounin



More information about the nginx-devel mailing list