We want to use ht geoip http server module on nginx. We installed everything according to this:
Then we activated the GeoIp2 (Core) Plugin, set geoip variables in general settings (everything left to the default value).
But i can’t activate the module (says not installed), and to the right the following is displayed: Note: Cannot find apache_get_modules function, assuming non-Apache webserver.
Matomo cannot find any GeoIP $_SERVER variables. You can configure used server variables [here]
what are we missing/how to troubleshoot?
Using the geoIP2 php function -> everything works, but we want to switch to the http module.
Thanks Lukas, i already did (before asking here of course). I created a test.php to dump the _server var, put it inside of matomo (allowed access throug nginx config) and the output doesn’t show any geoip vars.
All green on System Check and Tracking failures
Configuration for server variables used by GeoIP 2 server modules
GeoIP 2 (Php) and even Cloudflare work fine
Ok got it resolved, nginx.conf requires (watch out for correct path)
geoip2 /var/www/Matomo/misc/GeoLite2-City.mmdb
{
auto_reload 5m;
$geoip2_data_country_code default=US country iso_code;
$geoip2_data_country_name country names en;
$geoip2_data_city_name city names en;
}
And inside Matomo site config add variables
## only allow accessing the following php files
location ~ ^/(index|matomo|piwik|js/index).php {
include snippets/fastcgi-php.conf; # if your Nginx setup doesn't come with a default fastcgi-php config replace this with the one from this repository
fastcgi_param HTTP_PROXY ""; # prohibit httpoxy: https://httpoxy.org/
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; #replace with the path to your PHP socket file
#fastcgi_pass 127.0.0.1:9000; # uncomment if you are using PHP via TCP sockets
#Added for GeoIP2 to work
fastcgi_param MM_COUNTRY_CODE $geoip2_data_country_code;
fastcgi_param MM_COUNTRY_NAME $geoip2_data_country_name;
fastcgi_param MM_CITY_NAME $geoip2_data_city_name;
}