bubelov / nginx-alpine-geoip2

NGINX with a built-in GeoIP2 countries database
MIT License
14 stars 5 forks source link

How to use GeoLite2-City.mmdb on this image? #1

Open alyumitskij opened 4 years ago

alyumitskij commented 4 years ago

This is the best one, bro! But is it real to detect cities by GeoLite2-City.mmdb with this image? What should I edit to get it?

bubelov commented 4 years ago

@alyumitskij do you have that file? If so, just change the nginx.conf, rebuild and it should do the trick.

Here is how it looks now (link):

    # GeoIP2
    geoip2 /usr/share/geoip/GeoLite2-Country.mmdb {
        $geoip2_data_country_code source=$remote_addr country iso_code;
        $geoip2_data_country_name source=$remote_addr country names en;
    }

You might want to add another file just below, so it would look like this:

    # GeoIP2 countries
    geoip2 /usr/share/geoip/GeoLite2-Country.mmdb {
        $geoip2_data_country_code source=$remote_addr country iso_code;
        $geoip2_data_country_name source=$remote_addr country names en;
    }

    # GeoIP2 cities
    geoip2 /usr/share/geoip/GeoLite2-City.mmdb {
        $geoip2_data_city_name source=$remote_addr city names en;
    }

You would also need to add GeoLite2-City.mmdb to the Dockerfile, or mount it dynamically.

More on ngx_http_geoip2_module

How to get GeoLite2-City.mmdb, if you don't have it