Skip to content

redirect2me/cdn-geolocation

Repository files navigation

CDN Geolocation resolve.rs logo

Server that determines your physical location by looking at headers sent from various hosting providers and content delivery networks (CDNs).

Try it with: AWS CloudFront | Cloudflare | Fastly | Google AppEngine

Also see a more detailed comparison of geolocation providers

How it works

This application is just a simple app that shows various HTTP header values.

Running it yourself

It is a trivial go application. go run *.go should work. The real functionality is from the providers. Here are links and tips on how to set them up.

AWS CloudFront

Website | Official documentation | New detailed headers

CloudFront setup is not for the faint of heart. I managed to get it done in the end, but it involved a lot of fiddling. The rough steps are:

  1. Create a custom caching policy with the Cloudfront-Viewer-* headers
  2. Create an origin request policy with the Cloudfront-Viewer-* headers
  3. Create the distribution with these policies, making sure all the infinite number of other options are correct

Good luck!

Cloudflare

Website | Official documentation

Very easy to setup: just make sure you have enabled the CloudFlare proxy in your Cloudflare DNS settings. The little cloud has to be orange:

cloudflare proxy enabled
Fastly

Website | Official documentation

You need to configure each header.

Fastly's free tier only allows http for custom domains. If you need https, you either have to pay or use the Fastly domain .global.ssl.fastly.net.

Google AppEngine

Website | Official documentation

No special setup required, but your app has to be running on Google AppEngine.

Contributions

Contributions are welcome! If you know of any other similar CDNs/services, let me know & I will add them in!

API

There is a simple JSON/JSONP API that is free for light, non-commercial use. This is such a trivial application that you should run your own copy (or make your own version) for anything serious. Both AppEngine and Cloudflare have generous free plans (which is what I'm using).

Send a callback parameter to get JSONP instead of JSON.

License

GNU Affero General Public License v3.0

Credits

AWS Cloudflare Fastly Git Github golang Google AppEngine svgrepo water.css

  • togo go run github.com/flazz/togo --pkg=main --name=faviconIco --input=assets/favicon.ico