Forum: NGINX Howto set geoip_country for IPv4 and IPv6 databases?

Posted by Patrick Lists (Guest)
on 2013-01-15 05:08
(Received via mailing list)
Hi,

Next to their IPv4 country and city database, Maxmind now also has an
IPv6 country and city database at http://dev.maxmind.com/geoip/geolite

Is there a way I can make geo use the IPv6 databases too?

This does not work:

geoip_country /etc/nginx/GeoIP.dat;
geoip_country /etc/nginx/GeoIPv6.dat;
geoip_city /etc/nginx/GeoLiteCity.dat;
geoip_city /etc/nginx/GeoLiteCityv6.dat;

Because I see this error when checking the config:

nginx: [emerg] "geoip_country" directive is duplicate in
/etc/nginx/nginx.conf:116

Thanks for any advice.

Regards,
Patrick
Posted by "Bruno Prémont" <bruno.premont@restena.lu> (Guest)
on 2013-01-15 09:09
Attachment: nginx-1.2.2-geoip.patch (9,87 KB)
(Received via mailing list)
Hi,

It should be sufficient to just list the IPv6 database (which includes
the IPv4 database as mapped addresses) tough 1.2.x branch needs
attached patch.

I don't know if Maxim has already applied it or a variant of it to
1.3.x branch.


Also search the archives for GeoIP and IPv6 support, there were a few
posts about it.


Attached patch was initially posted in
http://mailman.nginx.org/pipermail/nginx-devel/201...
(though I've updated it for 1.2.2).

Regards,
Bruno
Posted by Ruslan Ermilov (Guest)
on 2013-01-15 14:36
(Received via mailing list)
On Tue, Jan 15, 2013 at 09:08:30AM +0100, Bruno Prmont wrote:
> It should be sufficient to just list the IPv6 database (which includes
> the IPv4 database as mapped addresses) tough 1.2.x branch needs
> attached patch.
>
> I don't know if Maxim has already applied it or a variant of it to
> 1.3.x branch.

It's in the works, should be done real soon now.
Posted by Patrick Lists (Guest)
on 2013-01-15 17:22
(Received via mailing list)
Hi Ruslan,

On 01/15/2013 02:36 PM, Ruslan Ermilov wrote:
> On Tue, Jan 15, 2013 at 09:08:30AM +0100, Bruno Prmont wrote:
>> It should be sufficient to just list the IPv6 database (which includes
>> the IPv4 database as mapped addresses) tough 1.2.x branch needs
>> attached patch.
>>
>> I don't know if Maxim has already applied it or a variant of it to
>> 1.3.x branch.
>
> It's in the works, should be done real soon now.

Thanks, that's good to know. I'll wait for the new 1.3 release with this
functionality and report back.

Regards,
Patrick
Posted by Rancor (Guest)
on 2013-04-30 12:15
(Received via mailing list)
Hi,

i'm trying to get this to work with the current NginX package 1.4.0 from
dotdeb.org (using  --with-ipv6) on a debian squeeze system. When 
downloading
the GeoIP ipv6 binary from:

http://dev.maxmind.com/geoip/geolite

and changing:

geoip_country   /etc/nginx/GeoIP.dat;

to:

geoip_country   /etc/nginx/GeoIPv6.dat;

in my nginx.conf i'm getting this message after reload:

nginx: [emerg] invalid GeoIP database "/etc/nginx/GeoIPv6.dat" type:12 
in
/etc/nginx/nginx.conf:47

Any hints what's wrong here? Thanks in advance for a reply.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,235108,238735#msg-238735
Posted by Ruslan Ermilov (Guest)
on 2013-04-30 14:34
(Received via mailing list)
On Tue, Apr 30, 2013 at 06:14:54AM -0400, Rancor wrote:
> geoip_country   /etc/nginx/GeoIP.dat;
> Any hints what's wrong here? Thanks in advance for a reply.
This happens if nginx is built without IPv6 support:

$ nginx -p . -c x.conf -t
nginx: [emerg] invalid GeoIP database "GeoIPv6.dat" type:12 in 
./x.conf:9
nginx: configuration file ./x.conf test failed
$ sed -ne9p x.conf
    geoip_country GeoIPv6.dat;

If OTOH nginx is built with proper IPv6 support:
$ nginx -p . -c x.conf -t
nginx: the configuration file ./x.conf syntax is ok
nginx: configuration file ./x.conf test is successful

Make sure your nginx is built with IPv6 support.
Posted by Rancor (Guest)
on 2013-04-30 15:03
(Received via mailing list)
Hey,

thanks for your reply. The packages of dotdeb.org are build with IPv6
support. When i'm using:

nginx -V

the output contains:

--with-ipv6

Additional netstat -npl shows this output:

tcp6       0      0 :::80                   :::* 
LISTEN
   4942/nginx
tcp6       0      0 :::443                  :::* 
LISTEN
   4942/nginx

so this NginX should run with IPv6?

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,235108,238743#msg-238743
Posted by Ruslan Ermilov (Guest)
on 2013-04-30 23:17
(Received via mailing list)
On Tue, Apr 30, 2013 at 09:03:20AM -0400, Rancor wrote:
>
> Additional netstat -npl shows this output:
>
> tcp6       0      0 :::80                   :::*                    LISTEN
>    4942/nginx
> tcp6       0      0 :::443                  :::*                    LISTEN
>    4942/nginx
>
> so this NginX should run with IPv6?

nginx detects the IPv6 support in libgeoip by trying to compile
the following code snippet:

#include <stdio.h>
#include <GeoIP.h>

int
main(void)
{
        printf("%d\n", GEOIP_CITY_EDITION_REV0_V6);
        return (0);
}

Does it compile OK on your system?
Posted by Rancor (Guest)
on 2013-05-01 11:15
(Received via mailing list)
Ruslan Ermilov Wrote:
-------------------------------------------------------
> {
>         printf("%d\n", GEOIP_CITY_EDITION_REV0_V6);
>         return (0);
> }
>
> Does it compile OK on your system?
>

Hi,

thanks again for your reply. The code above doesn't compile on my 
system:

test.c: In function ‘main’:
test.c:7: error: ‘GEOIP_CITY_EDITION_REV0_V6’ undeclared (first use in 
this
function)
test.c:7: error: (Each undeclared identifier is reported only once
test.c:7: error: for each function it appears in.)

Seems that the libgeoip1 in debian squeeze in version 1.4.7~beta6+dfsg-1
doesn't support this. Will test this again when wheezy is released at 
the
next weekend.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,235108,238763#msg-238763
Posted by Rancor (Guest)
on 2013-05-09 02:51
(Received via mailing list)
Hi,

> Seems that the libgeoip1 in debian squeeze in version
> 1.4.7~beta6+dfsg-1 doesn't support this. Will test this again when
> wheezy is released at the next weekend.

just want to let you know that this is now working on debian wheezy
with libgeoip1 version 1.4.8+dfsg-3

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,235108,239043#msg-239043
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.