Comment by louison11
2 years ago
If you don't want to do this yourself, you can actually just get Cloudflare to do it for you for free using a simple Worker since all Cloudflare requests contain approximate IP location information.
You can also just send a request to my URL (Cloudflare Worker operated - so it should have global low latency): https://www.edenmaps.net/iplocation
Use it for small applications, I don't mind. Just don't start sending me 10M requests per day ;-)
Or you download an IP database rather than sharing with a third party which IP address is likely connecting to your service with a third party
Located 100km from the Somali coast... I'm in Brussels, Belgium, thx for protecting my privacy :D
The result is [lon, lat]. You’ve most likely copied it onto Google maps, which works with [lat, lon]. Believe it or not, the industry still hasn’t come up with a standard order.
You could also just return a json with lat and lon as fields so nobody is getting confused. {lat:5, lon:7}
Got me to within 1km, that's pretty crazy
Same here. Scaring.
Does anyone know how accurate Cloudflare geolocation is (for workers requests)?
As accurate as MaxMind[1], since that's what they use [2]. In my experience, it's reasonably accurate for the US, less so for other countries. MaxMind publishes some accuracy data which might be an interesting starting point [3]
That said, for any analytics use cases of this data, be aware that MaxMind will group a lot of what should be unknowns in the middle of a country. Or, in the case the US now, I think they all end up in the middle of some lake, since some farm owners in Butler County, Kansas got tired of cops showing up and sued MaxMind. It can cause odd artifacts unless you filter the addresses out somehow.
1 https://developers.cloudflare.com/support/network/configurin...
2 https://www.maxmind.com/en/geoip-demo
3 https://www.maxmind.com/en/geoip2-city-accuracy-comparison
Yeah, MaxMind is the best I have used with caveats. You need to update it frequently, and you need to allow for overrides.
I work for IPinfo and we do ping based geolocation. The best thing you can do to verify geolocation accuracy is the following:
- Download a few free IP databases - Generate a random list of IP addresses - Do the IP address lookups across all those databases - Identify the IP address that can be pinged - Visit a site that can ping an IP address from multiple server - Sort the results by lowest avg ping time
Then check where the geolocation provider is locating the IP address and what is the nearest server from there.
On one hand, I love that there’s some good alternatives in the geolocation space, but misleading geolocation precision can lead to very undesirable side effects[0].
[0] https://www.theguardian.com/technology/2016/aug/09/maxmind-m...
1 reply →
This is excellent!
Would you mind open sourcing the code for that?
This is the code running this endpoint:
This is a function on Cloudflare Pages (which is just a different name for Cloudflare Workers). Minor adjustment needed for Workers (get rid of "context", I believe)
I'm in Munich. Cloudflare tells a position that is 730km to the north in a random forest.
You've inverted lat, lon.
No, the other one was in the ocean
[dead]