@@ -7,7 +7,28 @@ Description
77First install [ libmaxminddb] ( https://github.com/maxmind/libmaxminddb ) as described in its [ README.md
88file] ( https://github.com/maxmind/libmaxminddb/blob/master/README.md#installing-from-a-tarball ) .
99
10- Compile nginx:
10+ #### Download nginx source
11+ ```
12+ wget http://nginx.org/nginx-VERSION.tar.gz
13+ tar zxvf nginx-VERSION.tar.gz
14+ cd nginx-VERSION
15+ ```
16+
17+ ##### To build as a dynamic module (nginx 1.9.11+):
18+ ```
19+ ./configure --add-dynamic-module=/path/to/ngx_http_geoip2_module
20+ make
21+ make install
22+ ```
23+
24+ This will produce ``` objs/ngx_http_geoip2_module.so ``` . It can be copied to your nginx module path manually if you wish.
25+
26+ Add the following line to your nginx.conf:
27+ ```
28+ load_module modules/ngx_http_geoip2_module.so;
29+ ```
30+
31+ ##### To build as a static module:
1132```
1233./configure --add-module=/path/to/ngx_http_geoip2_module
1334make
@@ -33,5 +54,37 @@ http {
3354 $geoip2_data_city_name default=London city names en;
3455 }
3556 ....
57+
58+ fastcgi_param COUNTRY_CODE $geoip2_data_country_code;
59+ fastcgi_param COUNTRY_NAME $geoip2_data_country_name;
60+ fastcgi_param CITY_NAME $geoip2_data_city_name;
61+ ....
3662}
3763```
64+
65+ To find the path of the data you want (eg: city names en), use the [ mmdblookup tool] ( https://maxmind.github.io/libmaxminddb/mmdblookup.html ) :
66+
67+ ```
68+ $ mmdblookup --file /usr/share/GeoIP/GeoIP2-Country.mmdb --ip 8.8.8.8
69+
70+ {
71+ "country":
72+ {
73+ "geoname_id":
74+ 6252001 <uint32>
75+ "iso_code":
76+ "US" <utf8_string>
77+ "names":
78+ {
79+ "de":
80+ "USA" <utf8_string>
81+ "en":
82+ "United States" <utf8_string>
83+ }
84+ }
85+ }
86+
87+ $ mmdblookup --file /usr/share/GeoIP/GeoIP2-Country.mmdb --ip 8.8.8.8 country names en
88+
89+ "United States" <utf8_string>
90+ ```
0 commit comments