Coder Social home page Coder Social logo

redirect2me / cdn-geolocation Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 196 KB

Geolocation API via HTTP headers from a CDN, currently supporting AWS Cloudfront, Cloudflare, Fastly and Google AppEngine

License: GNU Affero General Public License v3.0

Go 99.92% Shell 0.08%
geolocation appengine appengine-go cloudflare aws-cloudfront ipgeolocation google-appengine cloudfront fastly geoip geolocation-api

cdn-geolocation's Introduction

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

cdn-geolocation's People

Contributors

fileformat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.