Redirect root route based on GeoLite2 country lookups.
If available in Hex, the package can be installed
by adding brando_geoip to your list of dependencies in mix.exs:
def deps do
[
{:brando_geoip, "~> 0.1.0"}
]
endDownload the GeoLite2 database by creating a MaxMind account here:
https://www.maxmind.com/en/account/login
then go to "GeoIP2/GeoLite2 > Download Files" in the side menu and download the GeoLite2 country db in mmdb format.
Place the file in ./media/GeoLite2-Country.mmdb
Add to your config.exs:
config :geolix,
databases: [
%{
id: :country,
adapter: Geolix.Adapter.MMDB2,
source: "./media/GeoLite2-Country.mmdb"
}
]Finally add BrandoGeoIP to your :browser pipeline after
RemoteIP in router.ex
pipeline :browser do
# ...
plug RemoteIp
plug BrandoGeoIP
# ...