| Since most CDNs are already doing GeoIP lookups (for request headers or log entries), you can leverage that to provide the data back in the response body via origin, worker or even CDN edge config. Programmatically populating the response body, as in the Cloudflare worker example from the post, is better than going to the origin just to echo some headers back in the response. To me, something like Fastly's VCL config language is even simpler. It directly executes on every CDN edge node worldwide upon request. For example, I just whipped this up on Fastly using VCL. It returns GeoIP as json data for your IP at the root path: http://geo.zombe.es Or if you want a particular IP, just append it to the path: http://geo.zombe.es/2a04:4e42:600::313 You could do the same via query params, headers, etc. Have URL endpoints that only return some of the data, and so forth. The VCL syntax gets a little gross when you handle quoting strings and assembling json and testing if the string is empty, but it gets the job done. Of course what you might want from GeoIP data may not be what you get. It's really kind of a useful kludge that gets treated sometimes as a panacea. This dataset right now thinks that I'm about 5 miles east of my location, but when subnets are repurposed it could be much more significant. And the data sources are always changing, so who knows what it will think tomorrow. |