diff --git a/conf.d/botblocker-nginx-settings.conf b/conf.d/botblocker-nginx-settings.conf index f56e9a62a..ba536c503 100644 --- a/conf.d/botblocker-nginx-settings.conf +++ b/conf.d/botblocker-nginx-settings.conf @@ -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; diff --git a/include_filelist.txt b/include_filelist.txt index da938b3eb..9abbce251 100755 --- a/include_filelist.txt +++ b/include_filelist.txt @@ -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 + " diff --git a/setup-ngxblocker b/setup-ngxblocker index fe8c6b0c4..3c15d8ef7 100755 --- a/setup-ngxblocker +++ b/setup-ngxblocker @@ -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