Difference between revisions of "GeoIP2"
From TMM Wiki
Jump to navigationJump to searchLine 7: | Line 7: | ||
There is a [https://dev.maxmind.com/geoip/geoip2/geolite2/ free] one available here | There is a [https://dev.maxmind.com/geoip/geoip2/geolite2/ free] one available here | ||
+ | You will need to download the 'Country' .mmdb file for both the paid and free one | ||
+ | |||
+ | This file needs to be on your NATS installation in a path that is accessible to NATS | ||
+ | The path will need to be specified in config->surfer->tracking GEOIP2_PHP_DATABASE_LOCATION | ||
<pre> | <pre> | ||
$config['IP_FILTER'] = 'GEOIP'; | $config['IP_FILTER'] = 'GEOIP'; |
Revision as of 18:36, 6 February 2019
Download and install the GeoIP database from Maxmind.
There is a free one available here
You will need to download the 'Country' .mmdb file for both the paid and free one
This file needs to be on your NATS installation in a path that is accessible to NATS The path will need to be specified in config->surfer->tracking GEOIP2_PHP_DATABASE_LOCATION
$config['IP_FILTER'] = 'GEOIP';
You can put it anywhere in the file except for after the last line.
Test Code
The following PHP code will help you test GeoIP. Put it in a file, put the file on your webserver, and load its URL. It should print your country's name.
<? echo 'According to geoip apache module, you are from '.apache_note("GEOIP_COUNTRY_NAME"); echo '<br>According to geoip pecl php module, you are from '.geoip_country_code_by_name($_SERVER['REMOTE_ADDR']); ?>
Note: Please be sure to perform this test after you install or update Maxmind's GeoIP.