matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.89k stars 2.65k forks source link

[Bug] Location resolution issue GeoiP database #22598

Closed kristoflarcher closed 1 month ago

kristoflarcher commented 1 month ago

What happened?

Hi, We use Matomo 5.0.3, deployed on Gcloud under an external Loadbalancer.

Loadbalancer forwards these requests headers to Matomo: X-Forwarded-For: 217.111.180.226, 34.98.115.97, 35.191.40.112 X-Forwarded-Host: dev-certinot.credoc.be X-Forwarded-Port: 443 X-Forwarded-Prefix: /matomo X-Forwarded-Proto: https X-Forwarded-Server: web-gateway-f5d6f8dbd-zxqql X-Forwarded-Uri: /matomo X-Real-Ip: 35.191.40.112

The x-forward header contains multiple address : the real client address is the frist one of the list Anf from what i know, if Multiple IPs in X-forward-for header, Matomo should use the first one by default but it 'seem not to be the case

and i set Matomo php config as follow ( to exclude proxies addresses ) [General] enable_location = 1 proxy_uri_header = 1 proxy_client_headers[] = "HTTP_X_FORWARDED_FOR" proxy_host_ips[] = "35.191../16" proxy_host_ips[] = "34.98../16"

From the console it s taken in account: ./console config:get --section="General" --key="proxy_host_ips" response : ["35.191../16","34.98../16","34.98.115.97","35.191.40.124"]

Geoip Database has been pushed to misc ( the free version and is taken in account ): But i still get a location from United state using Geop IP, I am still located in USA , address for proxy it seems

Thanks

What should happen?

I dont know how to solve, how to get a resolution from this first addres from x-forward-for header.

How can this be reproduced?

for any Visit to our website, we get a location resolution that points USA ( matomo displays this IP : 35.191.0.0 for the user WHERE AS it has been included proxy_host_ips )

Matomo version

5.0.3

PHP version

8.2.18

Server operating system

No response

What browsers are you seeing the problem on?

Chrome

Computer operating system

Windows 11

Relevant log output

No response

Validations

sgiehl commented 1 month ago

Hey @kristoflarcher,

Actually Matomo by default uses the last IP in the list. If you want to use the first IP instead you need to set proxy_ip_read_last_in_list = 0 in config. Let us know if it still doesn't work as expected when using this config setting.