automatic geoip update
This commit is contained in:
parent
14ec9f3e63
commit
bcd17dbea2
@ -8,7 +8,6 @@ RUN chmod +x /tmp/compile.sh && \
|
|||||||
COPY entrypoint.sh /opt/entrypoint.sh
|
COPY entrypoint.sh /opt/entrypoint.sh
|
||||||
COPY confs/ /opt/confs
|
COPY confs/ /opt/confs
|
||||||
COPY scripts/ /opt/scripts
|
COPY scripts/ /opt/scripts
|
||||||
COPY misc/*.mmdb /etc/nginx/geoip.mmdb
|
|
||||||
COPY fail2ban/ /opt/fail2ban
|
COPY fail2ban/ /opt/fail2ban
|
||||||
COPY logs/ /opt/logs
|
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/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/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;"
|
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
|
else
|
||||||
replace_in_file "/etc/nginx/nginx.conf" "%BLOCK_COUNTRY%" ""
|
replace_in_file "/etc/nginx/nginx.conf" "%BLOCK_COUNTRY%" ""
|
||||||
replace_in_file "/etc/nginx/server.conf" "%BLOCK_COUNTRY%" ""
|
replace_in_file "/etc/nginx/server.conf" "%BLOCK_COUNTRY%" ""
|
||||||
|
|||||||
Binary file not shown.
11
scripts/geoip.sh
Normal file
11
scripts/geoip.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/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
|
||||||
@ -1,8 +0,0 @@
|
|||||||
#!/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
|
|
||||||
Loading…
x
Reference in New Issue
Block a user