Welcome! Log In Create A New Profile

Advanced

How to get config $variable from module

Posted by edo888 
How to get config $variable from module
December 31, 2011 11:54AM
Hi,

I'm developing a filter module and here what I have in nginx.conf

set $var_name test;

module_config_var $var_name;

in the module commands I have this:

{ ngx_string("module_config_var"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_module_set_var,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_module_loc_conf_t, config_var),
NULL },

where:

static char * ngx_http_module_set_var(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
ngx_http_script_compile_t sc;

ngx_str_t *value;
ngx_array_t *lengths = NULL;
ngx_array_t *values = NULL;

value = cf->args->elts;

ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));

sc.cf = cf;
sc.source = &value[1];
sc.lengths = &lengths;
sc.values = &values;
sc.variables = 1;
sc.complete_lengths = 1;
sc.complete_values = 1;

if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_CONF_ERROR;
}

return NGX_CONF_OK;
}

After that in header filter if I try to get the conf->config_var it gives an empty string.

What am I missing? May be I need to run ngx_http_script_run at some point, but I don't know where.

Thanks in advance.



Edited 2 time(s). Last edit at 12/31/2011 12:04PM by edo888.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 198
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready