Merge pull request #159 from itoffshore/alpine

add check_nginx_directives()
This commit is contained in:
Stuart Cardall 2018-04-03 23:39:10 +01:00 committed by GitHub
commit e2c82c19c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 15 deletions

View file

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

View file

@ -4,7 +4,7 @@
# setup-ngxblocker # # setup-ngxblocker #
############################ ############################
######################################################################### #########################################################################
# _ __ _ # # _ __ _ #
# / |/ /__ _(_)__ __ __ # # / |/ /__ _(_)__ __ __ #
# / / _ `/ / _ \\ \ / # # / / _ `/ / _ \\ \ / #
@ -13,24 +13,24 @@
# / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ # # / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ #
# / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ # # / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ #
# /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ # # /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ #
######################################################################### #########################################################################
CONF_FILES=" CONF_FILES="
globalblacklist.conf globalblacklist.conf
botblocker-nginx-settings.conf botblocker-nginx-settings.conf
" "
BOT_FILES=" BOT_FILES="
blockbots.conf blockbots.conf
ddos.conf ddos.conf
custom-bad-referrers.conf custom-bad-referrers.conf
bad-referrer-words.conf bad-referrer-words.conf
blacklist-domains.conf blacklist-domains.conf
blacklist-ips.conf blacklist-ips.conf
blacklist-user-agents.conf blacklist-user-agents.conf
whitelist-domains.conf whitelist-domains.conf
whitelist-ips.conf whitelist-ips.conf
" "
VHOST_INCLUDES=" VHOST_INCLUDES="
blockbots.conf blockbots.conf
@ -42,3 +42,10 @@ SCRIPT_FILES="
setup-ngxblocker setup-ngxblocker
update-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 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() { get_options() {
local arg= opts= local arg= opts=
@ -414,6 +431,10 @@ main() {
fi fi
done done
# check nginx.conf for settings that clash
check_nginx_directives
# whitelisting
whitelist_ips $col_size whitelist_ips $col_size
if [ -d $WWW ]; then if [ -d $WWW ]; then