# GeoIP module questions

**URL:** <https://www.ruby-forum.com/t/geoip-module-questions/115511>\
**Category:** NGINX\
**Created:** [September 25, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511 "2007-09-25T22:03:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [September 25, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/1 "2007-09-25T22:03:42Z")

</div>

Hey there nginxers-

Is there a way to use a geoip database with nginx instead of  
explicitely listing out all the IP ranges in the nginx.conf?  
Something like this:

> **[GeoIP2 Country Database | MaxMind](https://www.maxmind.com/en/geoip2-country-database)**
>
> Use the GeoIP2 Country database to determine an Internet visitor's country based on their IP address.

There is a modeul for apache and lighttpd for this type of stuff.  
Any hints or help here? Or shoudl I just script something up to auto  
generate the geoip config for nginx from one of these databases?

Thanks!

– Ezra Z.  
– Founder & Ruby Hacker  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [September 25, 2007, 11:32pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/2 "2007-09-25T23:32:02Z")

</div>

Hello!

On Tue, 25 Sep 2007, Ezra Z. wrote:

> geoip config for nginx from one of these databases?  
> Hint 1:  
> You may use contrib/geo2nginx.pl script to convert maxmind’s geoip  
> database into nginx config format.

Hint 2:  
You may use “include” directive to include additional file into  
nginx.conf  
(e.g. your converted geoip database).

Maxim D.

---

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [September 25, 2007, 11:31pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/3 "2007-09-25T23:31:26Z")

</div>

[http://wiki.codemongers.com/NginxHttpGeoModule](http://wiki.codemongers.com/NginxHttpGeoModule)

- contrib/geo2nginx.pl to convert MaxMind CSV database.

ex:

geo $IP\_GEO

{  
default --;  
include /etc/nginx/geo\_ip\_country;  
}

and proxy\_set\_header / fastcgi\_param as usual

On 25.09.2007, at 23:52, Ezra Z. wrote:

> auto generate the geoip config for nginx from one of these databases?

Aleksej Besciokov  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
+7 495 7853149

---

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [January 25, 2008, 12:28pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/4 "2008-01-25T12:28:29Z")

</div>

quick, dumb follow up question on this…

what is the syntax for running geo2nginx.pl?

tried ./geo2nginx.pl GeoIPCountryWhois.csv geo.conf

and

./geo2nginx.pl GeoIPCountryWhois.csv \> geo.conf

to no avail.

the script looks quite simple, and i tried to RTFM i.e look at the  
script, but there’s no usage example, and it doesn’t look like there’s  
any switches.

i tried hunting around for some similar examples, no luck.

im sure this is really simple, considering there isn’t even a usage  
example, but im not very bright… i mean not a coder or perl guy…  
could somebody help a brother out on this one

thanks in advance

---

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [January 25, 2008, 3:04pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/5 "2008-01-25T15:04:06Z")

</div>

awesome, thanks!

---

<div class="post-metadata">

**Author:** ![ezra\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f07891/32.png) [@ezra\_z](https://www.ruby-forum.com/u/ezra_z)\
**Post date:** [January 25, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/geoip-module-questions/115511/6 "2008-01-25T12:49:43Z")

</div>

perl geo2nginx.pl \< GeoIPCountryWhois.csv \> geo.conf
