Commit bcd17dbe authored by bunkerity's avatar bunkerity
Browse files

automatic geoip update

parent 14ec9f3e
......@@ -8,7 +8,6 @@ RUN chmod +x /tmp/compile.sh && \
COPY entrypoint.sh /opt/entrypoint.sh
COPY confs/ /opt/confs
COPY scripts/ /opt/scripts
COPY misc/*.mmdb /etc/nginx/geoip.mmdb
COPY fail2ban/ /opt/fail2ban
COPY logs/ /opt/logs
......
......@@ -208,6 +208,10 @@ if [ "$BLOCK_COUNTRY" != "" ] ; then
replace_in_file "/etc/nginx/nginx.conf" "%BLOCK_COUNTRY%" "include /etc/nginx/geoip.conf;"
replace_in_file "/etc/nginx/server.conf" "%BLOCK_COUNTRY%" "include /etc/nginx/geoip-server.conf;"
replace_in_file "/etc/nginx/geoip.conf" "%BLOCK_COUNTRY%" "$(echo $BLOCK_COUNTRY | sed 's/ / no;\n/g') no;"
echo "0 0 2 * * /opt/scripts/geoip.sh" >> /etc/crontabs/root
if [ ! -f /etc/nginx/geoip.mmdb ] ; then
/opt/scripts/geoip.sh
fi
else
replace_in_file "/etc/nginx/nginx.conf" "%BLOCK_COUNTRY%" ""
replace_in_file "/etc/nginx/server.conf" "%BLOCK_COUNTRY%" ""
......
#!/bin/sh
# MMDB from https://db-ip.com/db/download/ip-to-country-lite
URL="https://download.db-ip.com/free/dbip-country-lite-$(date +%Y-%m).mmdb.gz"
wget -O /etc/nginx/geoip.mmdb.gz "$URL" > /dev/null 2>&1
if [ -f /etc/nginx/geoip.mmdb.gz ] ; then
gunzip -f /etc/nginx/geoip.mmdb.gz
if [ -f /run/nginx/nginx.pid ] ; then
/usr/sbin/nginx -s reload
fi
fi
#!/bin/sh
# wget "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=&suffix=tar.gz" -O toto.tar.gz
wget -O /etc/nginx/geoip.mmdb.gz https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz
gunzip -f /etc/nginx/geoip.mmdb.gz
if [ -f /run/nginx/nginx.pid ] ; then
/usr/sbin/nginx -s reload
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment