mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 10:40:36 +00:00
setup-ngxblocker: change resolver
* use ifconfig.co for ip resolution fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/178
This commit is contained in:
parent
a9ef73b12b
commit
5d494bdd63
1 changed files with 7 additions and 12 deletions
|
@ -108,21 +108,16 @@ find_vhosts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelist_ips() {
|
whitelist_ips() {
|
||||||
local ip= conf=$BOTS_DIR/whitelist-ips.conf col_size=$1
|
local ip= conf=$BOTS_DIR/whitelist-ips.conf
|
||||||
|
|
||||||
mkdir -p $BOTS_DIR
|
mkdir -p $BOTS_DIR
|
||||||
|
|
||||||
if [ -n "$(which dig)" ]; then
|
ip=$(curl -s ifconfig.co)
|
||||||
ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
|
if ! grep "$ip" $conf >/dev/null 2>&1; then
|
||||||
if ! grep "$ip" $conf >/dev/null 2>&1; then
|
printf "\n%-17s %-15s %-s\n" "Whitelisting ip:" "$ip" "=> $conf"
|
||||||
printf "\n%-17s %-15s %-s\n" "Whitelisting ip:" "$ip" "=> $conf"
|
if [ "$DRY_RUN" = "N" ]; then
|
||||||
if [ "$DRY_RUN" = "N" ]; then
|
printf "%-23s %-s\n" "$ip" "0;" >> $conf
|
||||||
printf "%-23s %-s\n" "$ip" "0;" >> $conf
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
printf "%-10s %-${col_size}s %-s\n" \
|
|
||||||
"WARN:" "dig binary missing" "=> install bind-tools to whitelist external ip address"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +430,7 @@ main() {
|
||||||
check_nginx_directives
|
check_nginx_directives
|
||||||
|
|
||||||
# whitelisting
|
# whitelisting
|
||||||
whitelist_ips $col_size
|
whitelist_ips
|
||||||
|
|
||||||
if [ -d $WWW ]; then
|
if [ -d $WWW ]; then
|
||||||
whitelist_domains
|
whitelist_domains
|
||||||
|
|
Loading…
Add table
Reference in a new issue