mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-01 18:19:55 +00:00
Test Whitelisting IPs REF: #201
This commit is contained in:
parent
84a8ad1eb5
commit
ab2368444d
3 changed files with 90 additions and 27 deletions
|
@ -45,7 +45,7 @@ echo "${bold}${green}-------------------------"
|
|||
printf "\n\n"
|
||||
|
||||
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf
|
||||
printf '%s\t%s\n' "${thisip}" "1;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf
|
||||
#printf '%s\t%s\n' "${thisip}" "1;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf
|
||||
printf '%s\t%s\n' "127.0.0.1" "1;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf
|
||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blacklist-ips.conf /etc/nginx/bots.d/blacklist-ips.conf
|
||||
|
||||
|
@ -55,10 +55,17 @@ echo "${bold}${green}--------------------"
|
|||
printf "\n\n"
|
||||
|
||||
sudo truncate -s 0 ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf
|
||||
printf '%s\t%s\n' "${thisip}" "0;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf
|
||||
#printf '%s\t%s\n' "${thisip}" "0;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf
|
||||
printf '%s\t%s\n' "127.0.0.1" "0;" >> ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf
|
||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/whitelist-ips.conf /etc/nginx/bots.d/whitelist-ips.conf
|
||||
|
||||
echo "${bold}${green}----------------------------"
|
||||
echo "${bold}${green}Copy modified blockbots.conf"
|
||||
echo "${bold}${green}----------------------------"
|
||||
printf "\n\n"
|
||||
|
||||
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/blockbots.conf /etc/nginx/bots.d/blockbots.conf
|
||||
|
||||
echo "${bold}${green}---------------"
|
||||
echo "${bold}${green}Reloading Nginx"
|
||||
echo "${bold}${green}---------------"
|
||||
|
@ -76,29 +83,14 @@ sleep 10s
|
|||
# Function Curl Test 1 - Test User Domain Whitelist
|
||||
# *************************************************
|
||||
|
||||
#run_curltest1 () {
|
||||
#if curl http://localhost:9000 -e http://www.myowndomain.com 2>&1 | grep -i 'Welcome'; then
|
||||
# echo "${bold}${green}PASSED - User whitelist-domains.conf working"
|
||||
#else
|
||||
# echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working"
|
||||
# #exit 1
|
||||
#fi
|
||||
#}
|
||||
#run_curltest1
|
||||
|
||||
# *************************************************
|
||||
# Function Curl Test 2 - Test User Domain Whitelist
|
||||
# *************************************************
|
||||
|
||||
#run_curltest2 () {
|
||||
#if curl http://localhost:9000 -e http://www.myotherdomain.com 2>&1 | grep -i 'Welcome'; then
|
||||
# echo "${bold}${green}PASSED - User whitelist-domains.conf working"
|
||||
#else
|
||||
# echo "${bold}${red}FAILED - User whitelist-domains.conf NOT working"
|
||||
# #exit 1
|
||||
#fi
|
||||
#}
|
||||
#run_curltest2
|
||||
run_curltest1 () {
|
||||
if curl http://localhost:9000 2>&1 | grep -i 'Welcome'; then
|
||||
echo "${bold}${green}PASSED - whitelist own ip is WORKING"
|
||||
else
|
||||
echo "${bold}${red}FAILED - whitelist own ip is NOT working"
|
||||
fi
|
||||
}
|
||||
run_curltest1
|
||||
|
||||
|
||||
echo "${bold}${green}-----------------------------"
|
||||
|
|
71
.dev-tools/test_units/blockbots.conf
Normal file
71
.dev-tools/test_units/blockbots.conf
Normal file
|
@ -0,0 +1,71 @@
|
|||
# Author: Mitchell Krog <mitchellkrog@gmail.com> - https://github.com/mitchellkrogza/
|
||||
|
||||
### VERSION INFORMATION #
|
||||
###################################################
|
||||
### Version: V4.2019.03
|
||||
### Updated: 2019-06-24
|
||||
###################################################
|
||||
### VERSION INFORMATION ##
|
||||
|
||||
|
||||
##############################################################################
|
||||
# _ __ _ #
|
||||
# / |/ /__ _(_)__ __ __ #
|
||||
# / / _ `/ / _ \\ \ / #
|
||||
# /_/|_/\_, /_/_//_/_\_\ #
|
||||
# __/___/ __ ___ __ ___ __ __ #
|
||||
# / _ )___ ____/ / / _ )___ / /_ / _ )/ /__ ____/ /_____ ____ #
|
||||
# / _ / _ `/ _ / / _ / _ \/ __/ / _ / / _ \/ __/ '_/ -_) __/ #
|
||||
# /____/\_,_/\_,_/ /____/\___/\__/ /____/_/\___/\__/_/\_\\__/_/ #
|
||||
# #
|
||||
##############################################################################
|
||||
|
||||
# Include this in a vhost file within a server {} block using and include statement like below
|
||||
|
||||
# server {
|
||||
# #Config stuff here
|
||||
# include /etc/nginx/bots.d/blockbots.conf
|
||||
# include /etc/nginx/bots.d/ddos.conf
|
||||
# #Other config stuff here
|
||||
# }
|
||||
|
||||
#######################################################################
|
||||
|
||||
# ENABLE WHITELISTING TO WORK
|
||||
# This should over rule any other rule
|
||||
if ($remote_addr ~ "(127.0.0.1)" ) {
|
||||
#set $bad_bot '0';
|
||||
set $validate_client '0';
|
||||
}
|
||||
|
||||
|
||||
# BOTS
|
||||
# ****
|
||||
#limit_conn bot1_connlimit 100;
|
||||
limit_conn bot2_connlimit 10;
|
||||
#limit_req zone=bot1_reqlimitip burst=50;
|
||||
limit_req zone=bot2_reqlimitip burst=10;
|
||||
if ($bad_bot = '3') {
|
||||
return 444;
|
||||
}
|
||||
|
||||
# BAD REFER WORDS
|
||||
# ***************
|
||||
if ($bad_words) {
|
||||
return 444;
|
||||
}
|
||||
|
||||
|
||||
# REFERERS
|
||||
# ********
|
||||
if ($bad_referer) {
|
||||
return 444;
|
||||
}
|
||||
|
||||
# IP BLOCKS
|
||||
# *********
|
||||
if ($validate_client) {
|
||||
return 444;
|
||||
}
|
||||
|
||||
#######################################################################
|
|
@ -51,8 +51,8 @@ script:
|
|||
- bash .dev-tools/test-blocker-badwords.sh
|
||||
- bash .dev-tools/test-blocker-whitelist-domains.sh
|
||||
- bash .dev-tools/test-blocker-whitelist-ips.sh
|
||||
- bash .dev-tools/test-blocker-rate-limiting.sh
|
||||
- bash .dev-tools/test-blocker-whitelist.sh
|
||||
#- bash .dev-tools/test-blocker-rate-limiting.sh
|
||||
#- bash .dev-tools/test-blocker-whitelist.sh
|
||||
- bash .dev-tools/modify-files-and-commit.sh
|
||||
|
||||
before_deploy:
|
||||
|
|
Loading…
Add table
Reference in a new issue