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

**URL:** <https://www.ruby-forum.com/t/read-a-local-variable-http-variable-from-config-file-in-c/194120>\
**Category:** NGINX\
**Created:** [August 30, 2010, 6:32pm UTC](https://www.ruby-forum.com/t/read-a-local-variable-http-variable-from-config-file-in-c/194120 "2010-08-30T18:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![breaks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e68b1a/32.png) [@breaks](https://www.ruby-forum.com/u/breaks)\
**Post date:** [August 30, 2010, 6:32pm UTC](https://www.ruby-forum.com/t/read-a-local-variable-http-variable-from-config-file-in-c/194120/1 "2010-08-30T18:32:00Z")

</div>

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:

> **[Read a local variable / http variable from config file in C \[dev\]](https://forum.nginx.org/read.php?2,125270,125270#msg-125270)**
>
> 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 - {...

---

<div class="post-metadata">

**Author:** ![breaks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e68b1a/32.png) [@breaks](https://www.ruby-forum.com/u/breaks)\
**Post date:** [December 17, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/read-a-local-variable-http-variable-from-config-file-in-c/194120/2 "2010-12-17T12:04:59Z")

</div>

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

Thanks, Michal

Posted at Nginx Forum:

> **[Re: Read a local variable / http variable from config file in C \[dev\]](https://forum.nginx.org/read.php?2,125270,159360#msg-159360)**
>
> 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 - {...
