diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed0c131 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.mmdb +geoupdate/.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e241ce0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +ARG NGINX_VERSION=1.19.2 + +FROM nginx:$NGINX_VERSION + +ARG NGINX_VERSION=1.19.2 +ARG GEOIP2_VERSION=3.3 + +RUN mkdir -p /var/lib/GeoIP/ + +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + libpcre++-dev \ + zlib1g-dev \ + libgeoip-dev \ + libmaxminddb-dev \ + wget \ + git + +RUN cd /opt \ + && git clone --depth 1 -b $GEOIP2_VERSION --single-branch https://github.com/leev/ngx_http_geoip2_module.git \ + && wget -O - http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | tar zxfv - \ + && mv /opt/nginx-$NGINX_VERSION /opt/nginx \ + && cd /opt/nginx \ + && ./configure --with-compat --add-dynamic-module=/opt/ngx_http_geoip2_module \ + && make modules + +FROM nginx:$NGINX_VERSION + +COPY --from=0 /opt/nginx/objs/ngx_http_geoip2_module.so /usr/lib/nginx/modules + +RUN apt-get update \ + && apt-get install -y --no-install-recommends --no-install-suggests libmaxminddb0 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && chmod -R 644 /usr/lib/nginx/modules/ngx_http_geoip2_module.so \ + && sed -i '1iload_module \/usr\/lib\/nginx\/modules\/ngx_http_geoip2_module.so;' /etc/nginx/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1c27cf8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' + +services: + geoupdate: + image: maxmindinc/geoipupdate + env_file: ./geoupdate/.env + volumes: + - ./geoupdate:/usr/share/GeoIP + + nginx: + build: . + container_name: nginx-geo + volumes: + - ./geoupdate/GeoLite2-Country.mmdb:/var/lib/GeoIP/GeoLite2-Country.mmdb + - ./conf/nginx.conf:/etc/nginx/nginx.conf + - ./conf/site.conf:/etc/nginx/conf.d/default.conf + ports: + - 80:80 diff --git a/img/country_restricted_service_nginx_docker_geoip2.png b/img/country_restricted_service_nginx_docker_geoip2.png new file mode 100644 index 0000000..05803b4 Binary files /dev/null and b/img/country_restricted_service_nginx_docker_geoip2.png differ diff --git a/img/country_restricted_service_nginx_docker_geoip2.xcf b/img/country_restricted_service_nginx_docker_geoip2.xcf new file mode 100644 index 0000000..2b2f46c Binary files /dev/null and b/img/country_restricted_service_nginx_docker_geoip2.xcf differ