IP geolocation microservice
Branch: master
Clone or download
Pull request Compare This branch is 8 commits ahead of udacity:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
Main.hs
README.md
Setup.hs
geode.cabal
swagger.json

README.md

About

Geode is a simple Web frontend for MaxMind's GeoIP2 City database.

Setup

Purchase a GeoIP2 City database, or grab a free GeoLite2 City database from MaxMind:

$ curl https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz |
  gunzip > GeoLite2-City.mmdb

Prep Cabal for building/running Geode:

$ cabal sandbox init
$ cabal install -j --only-dependencies

Usage

Fire up Geode:

$ GEOIP_DB=GeoLite2-City.mmdb SERVICE_PORT=3000 cabal run
Running geode...
Setting phasers to stun... (port 3000) (ctrl-c to quit)

Try it out:

$ curl localhost:3000/138.197.198.15
{
    "regionName": "California",
    "latitude": 37.3483,
    "postalCode": "95051",
    "city": "Santa Clara",
    "countryName": "United States",
    "countryCode": "US",
    "region": "CA",
    "longitude": -121.9844,
    "continentCode": "NA",
    "continent": "North America"
}

If you make a request to / (leaving off any IP address) Geode will look up your IP address, checking for any X-Forwarded-For header, then falling back to the socket address of your client.