Hosting My Own Geofeed (and Making Sure It Actually Works)
Setting up a geofeed for IP geolocation and debugging MIME type issues.
What's a Geofeed?
A geofeed serves as a CSV file enabling geolocation service providers to connect IP address ranges with their geographic locations. This proves especially valuable for organizations operating independent networks or distributed services seeking optimal regional content delivery and latency-based routing performance.
Example entries from my geofeed:
2a0e:97c0:e60::/48,DE,DE-BY,Falkenstein
2a0e:97c0:e61::/48,US,US-NY,New York City
2a0e:97c0:e62::/48,SE,SE-AB,Stockholm
2a13:c007:8400::/48,US,US-NY,New York City
How I'm Hosting It
I initially deployed this file through an nginx container behind a Caddy reverse proxy, which functioned adequately but presented complications.
The Problem: MIME Types
nginx was transmitting the file as "application/octet-stream," which works for browsers but causes issues when geolocation providers expect "text/csv" formatting. I noted that isp.google.com always kept saying there was an issue with one of the rows.
Rather than implementing MIME type corrections in either nginx or Caddy, I opted for a cleaner approach.
The Solution: Let Caddy Handle It
The geofeed was relocated directly onto the Caddy server as a static file, eliminating unnecessary complexity. Caddy automatically assigns the appropriate Content-Type: text/csv header, resolving the compatibility issues.
Final Thoughts
Operating your own IP address space and hosting a geofeed represents a straightforward method for improving IP geolocation accuracy across major databases.