Skip to content

Instantly share code, notes, and snippets.

@SushiFu
Created January 15, 2019 23:06
Show Gist options
  • Save SushiFu/4fc428b72b2ecc02bf5f4b20d15b43a3 to your computer and use it in GitHub Desktop.
Save SushiFu/4fc428b72b2ecc02bf5f4b20d15b43a3 to your computer and use it in GitHub Desktop.
Use MaxMind GeoLite2 Country w/ nginx Docker image
FROM python:latest as geoip
RUN git clone https://github.com/makhomed/nginx-geo.git nginx-geo && \
nginx-geo/nginx-geo --download --convert --work-dir /
FROM nginx:stable
COPY ./config /etc/nginx
COPY --from=geoip /geoip_country_code.conf /etc/nginx/geoip/geoip_country_code.conf
## [...]
http {
## [...]
geo $geoip_country_code {
proxy_recursive;
default US;
include /etc/nginx/geoip/geoip_country_code.conf;
}
## $geoip_country_code variable is available w/ 'US' fallback value
}
# daemon off;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment