Read a local variable / http variable from config file in C

Hello,

I write a new module to nginx, and I have a small problem, because I
don’t know how I can read local/http variable (for example from GeoIP
module) from nginx configuration file in my module. Below is a piece of
my code :

my_module.c

{ ngx_string(“my_language”),

NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_HTTP_SIF_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_my_loc_conf_t, language),
NULL },

nginx.conf


geoip_country_file /usr/local/nginx/GeoIP.dat;

my_language $geoip_country_code;

But in the variable language in ngx_http_my_loc_conf_t struct, I have
string not parsed “$geoip_country_code” not a “US”. GeoIP module works,
I checked.

Please for any suggestions,
Thanks in advance.

Posted at Nginx Forum:

Hello,
I have the same problem. How can I get the value of a variable from
nginx.conf?

Thanks, Michal

Posted at Nginx Forum: