chores: geoip2 and nginx for geo aware services
This commit is contained in:
parent
1fba36c6f9
commit
ab1331c80a
5 changed files with 57 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.mmdb
|
||||||
|
geoupdate/.env
|
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
@ -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
|
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
|
@ -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
|
BIN
img/country_restricted_service_nginx_docker_geoip2.png
Normal file
BIN
img/country_restricted_service_nginx_docker_geoip2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
img/country_restricted_service_nginx_docker_geoip2.xcf
Normal file
BIN
img/country_restricted_service_nginx_docker_geoip2.xcf
Normal file
Binary file not shown.
Loading…
Reference in a new issue