-
-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve IP Logging for Analytics #384
Comments
Here's some additional information regarding how Cloudflare handles HTTP Request Headers in regards to IP addresses. There's also a header which supplies the country code of the originating visitor, so maybe if the IP is unavailable for some reason, we can still log the Country via that? |
Accurately detecting the location of 100% of visits is virtually impossible. Sometimes there are IP addresses that cannot be found in the GeoIp database or the fallback geolocation API, or they can only be partially located (we have the country, but not the city). Also, there are visitors which do not send any IP address. It is there when real users visit the link from a browser, but if you share a link on Twitter (for example), you will automatically see several visits from their crawlers which cannot be located. This applies to any other kind of web bot. This kind of visits are currently included with the rest. You can determine how many visits are not coming from real users based on the browser's chart. Those that did not provide a user agent that can be matched to a standard browser, are probably not real users. Then shlink makes use of this library in order to determine the address https://github.com/akrabat/ip-address-middleware It checks for the most common and standard headers where IP addresses usually live, but those headers can be configured, so if cloudflare is using some non-standard header, it should be easy to include. I will take a look at the docs. |
I will include this in next release, inspecting requests for the next list of headers. $headersToInspect = [
'X-Real-Ip',
'CF-Connecting-IP',
'True-Client-IP',
'Forwarded',
'X-Forwarded-For',
'X-Forwarded',
'X-Cluster-Client-Ip',
'Client-Ip',
]; That should cover most of the cases. |
It'd be awesome if some work could be put into IP fetching, we currently see about a 30% average rate of "unknown" IPs.
I'm not sure how this is even possible as every request has to come from an IP.
Any insight?
The text was updated successfully, but these errors were encountered: