add check_nginx_directives()

* check for & disable conflicting nginx directives in conf.d/botblocker-nginx-settings.conf

   fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/156

 * tidy up some whitespace in include_filelist.txt
This commit is contained in:
Stuart Cardall 2018-04-03 22:21:38 +00:00
parent e00df71ebc
commit b49fd65b5f
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6
3 changed files with 44 additions and 15 deletions

View file

@ -11,6 +11,7 @@
##############################################################################
# Version 1.1
# ! new directives also to be added to include_filelist.txt ! #
server_names_hash_bucket_size 128;
server_names_hash_max_size 4096;

View file

@ -4,7 +4,7 @@
# setup-ngxblocker #
############################
#########################################################################
#########################################################################
# _ __ _ #
# / |/ /__ _(_)__ __ __ #
# / / _ `/ / _ \\ \ / #
@ -13,24 +13,24 @@
# / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ #
# / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ #
# /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ #
#########################################################################
#########################################################################
CONF_FILES="
globalblacklist.conf
botblocker-nginx-settings.conf
"
globalblacklist.conf
botblocker-nginx-settings.conf
"
BOT_FILES="
blockbots.conf
ddos.conf
custom-bad-referrers.conf
bad-referrer-words.conf
blacklist-domains.conf
blacklist-ips.conf
blacklist-user-agents.conf
whitelist-domains.conf
whitelist-ips.conf
"
blockbots.conf
ddos.conf
custom-bad-referrers.conf
bad-referrer-words.conf
blacklist-domains.conf
blacklist-ips.conf
blacklist-user-agents.conf
whitelist-domains.conf
whitelist-ips.conf
"
VHOST_INCLUDES="
blockbots.conf
@ -42,3 +42,10 @@ SCRIPT_FILES="
setup-ngxblocker
update-ngxblocker
"
NGINX_DIRECTIVES="
server_names_hash_bucket_size
server_names_hash_max_size
limit_req_zone
limit_conn_zone
"

View file

@ -283,6 +283,23 @@ check_depends() {
fi
}
check_nginx_directives() {
# avoid directive conflicts with nginx.conf
local x= bot_config="$CONF_DIR"/botblocker-nginx-settings.conf
# directives sourced from include_filelist.txt
for x in $NGINX_DIRECTIVES; do
if grep -E "(^$x|^[[:space:]]+$x)" 1>/dev/null $MAIN_CONF; then
printf "${BOLDYELLOW}setup will fix conflict from: '$x' in $bot_config${RESET}\n"
if [ "$DRY_RUN" = "N" ]; then
printf "${BOLDRED}disabling '$x' in: $bot_config${RESET}\n"
sed "s|$x|#$x|" $bot_config | grep $x
printf " ${BOLDGREEN}disabled OK${RESET}\n\n"
fi
fi
done
}
get_options() {
local arg= opts=
@ -414,6 +431,10 @@ main() {
fi
done
# check nginx.conf for settings that clash
check_nginx_directives
# whitelisting
whitelist_ips $col_size
if [ -d $WWW ]; then