@DenisVS opened this Issue on July 23rd 2019

This is a copy of my issue from the official forum, because there are still no answers.
https://forum.matomo.org/t/geoip-2-doesnt-show-visitors-data/33452
After setting up, my server provides the necessary HTTP headers:

["HTTP_X_REAL_IP"]=>
  string(12) "51.15.106.67"
  ["HTTP_GEOIP2_AUTONOMOUS_SYSTEM_NUMBER"]=>
  string(5) "12876"
  ["HTTP_GEOIP2_AUTONOMOUS_SYSTEM_ORGANIZATION"]=>
  string(13) "Online S.a.s."
  ["HTTP_GEOIP2_CONTINENT_CODE"]=>
  string(2) "EU"
  ["HTTP_GEOIP2_CONTINENT_GEONAME_ID"]=>
  string(7) "6255148"
  ["HTTP_GEOIP2_CONTINENT_NAMES"]=>
  string(6) "Europe"
  ["HTTP_GEOIP2_COUNTRY_GEONAME_ID"]=>
  string(7) "2750405"
  ["HTTP_GEOIP2_COUNTRY_ISO_CODE"]=>
  string(2) "NL"
  ["HTTP_GEOIP2_COUNTRY_NAMES"]=>
  string(11) "Netherlands"
  ["HTTP_GEOIP2_LOCATION_ACCURACY_RADIUS"]=>
  string(3) "500"
  ["HTTP_GEOIP2_LOCATION_LATITUDE"]=>
  string(8) "52.38240"
  ["HTTP_GEOIP2_LOCATION_LONGITUDE"]=>
  string(7) "4.89950"
  ["HTTP_GEOIP2_LOCATION_TIME_ZONE"]=>
  string(16) "Europe/Amsterdam"
  ["HTTP_GEOIP2_REGISTERED_COUNTRY_GEONAME_ID"]=>
  string(7) "2750405"
  ["HTTP_GEOIP2_REGISTERED_COUNTRY_ISO_CODE"]=>
  string(2) "NL"
  ["HTTP_GEOIP2_REGISTERED_COUNTRY_NAMES"]=>
  string(11) "Netherlands"

My configuration for server variables is remapped appropriately:

HTTP_GEOIP2_CONTINENT_CODE   Default: MM_CONTINENT_CODE 
HTTP_GEOIP2_CONTINENT_NAMES  Default: MM_CONTINENT_NAME 
HTTP_GEOIP2_COUNTRY_ISO_CODE     Default: MM_COUNTRY_CODE 
HTTP_GEOIP2_COUNTRY_NAMES    Default: MM_COUNTRY_NAME 
HTTP_GEOIP2_LOCATION_LATITUDE    Default: MM_LATITUDE 
HTTP_GEOIP2_LOCATION_LONGITUDE   Default: MM_LONGITUDE 
HTTP_GEOIP2_POSTAL_CODE  Default: MM_POSTAL_CODE 
HTTP_GEOIP2_CITY_NAMES   Default: MM_CITY_NAME 
HTTP_GEOIP2_AUTONOMOUS_SYSTEM_NUMBER     Default: MM_ISP 
HTTP_GEOIP2_AUTONOMOUS_SYSTEM_ORGANIZATION       Default: MM_ORG 

cd1a51e9848c3ab61910a5dfaeab88b92d154adf
But all information about users in real-time section is the IP and location based on browser language settings.
When I run test in console it give something like:

> php /path/to/my/site/piwik/console diagnostics:run
Geolocation: WARNING The default location provider guesses a visitor's country based on the language they use. This is not very accurate, so we recommend installing and using GeoIP.
1 warnings detected

What’s wrong?

@tsteur commented on July 23rd 2019 Member

The command line might be wrong since apache wouldn't set the headers there. I suppose you can ignore it and rely on the UI which tells you that GeoIP2 Apache is being used.

It seems otherwise like some server setup issue which we can't provide support here in the issue tracker unfortunately as this is quite server specific.

In the screen you posted it looks like generally the location is being detected? It shows the right ORG etc. which it wouldn't be able to detect from the language provider.

@DenisVS commented on July 24th 2019

Well, I created the headers in accordance with the requested by UI. It gets exactly what it wants.
I'm trying to make what can be detected anyway.
What should I do, what conditions should I provide besides those headers?

@tsteur commented on July 24th 2019 Member

I'm trying to make what can be detected anyway.
What should I do, what conditions should I provide besides those headers?

Sorry I'm not quite 100% sure what you mean?

@DenisVS commented on July 24th 2019

I just want it to correctly determine geodata.
And I can alter the http headers of server to some extent for it.

@tsteur commented on July 24th 2019 Member

Sorry I'm still not understanding what you mean? In the UI it looks like things are already working and you correctly determine geodata? @sgiehl do you maybe know more here?

@DenisVS commented on July 25th 2019

Visibility of the correct data only on the settings page.
It seems that in the log geodata represents "as is".
Clipboard Image (25 July 2019)

@sgiehl commented on July 25th 2019 Member

@DenisVS are you using JS tracking or log import?

@DenisVS commented on July 25th 2019

JS via tracker-proxy

@sgiehl commented on July 25th 2019 Member

That might possibly the issue. Haven't had a closer look at the proxy script. But apache sets the variables based on the IP of the request. Which would be the one of the server when the request is proxied with curl. The correct IP is send with the tracking data, so it's displayed correctly in Matomo, but Apache doesn't see it and can't locate the IP correctly.
Maybe the proxy script needs to be adjusted, so the IP is sent as "X-Forwarded-For" Header or similar with curl, so you can configure Apache to use that if available.

@tsteur commented on July 25th 2019 Member

It's already doing this maybe @sgiehl https://github.com/matomo-org/tracker-proxy/blob/master/proxy.php#L192-L196 ?

Seems like we can close the issue and @DenisVS would maybe need to configure to use the correct IP in apache?

@sgiehl commented on July 26th 2019 Member

@tsteur that is only used to determine the IP that is sent as cip in the tracking request. The curl request in https://github.com/matomo-org/tracker-proxy/blob/master/proxy.php#L304-L334 is send with the server ip address and doesn't have a additional "X-Forwarded-For" Header or similar

@tsteur commented on July 28th 2019 Member
This Issue was closed on July 28th 2019
Powered by GitHub Issue Mirror