fixing scripts again and again
This commit is contained in:
parent
db04c0345c
commit
2fe05d3fd3
@ -1,5 +0,0 @@
|
|||||||
map $http_referer $bad_referrer {
|
|
||||||
hostnames;
|
|
||||||
default no;
|
|
||||||
%BLOCK_REFERRER%
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
map $http_user_agent $bad_user_agent {
|
|
||||||
default no;
|
|
||||||
%BLOCK_USER_AGENT%
|
|
||||||
}
|
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ ! -f "/etc/nginx/map-referrer.conf" ] ; then
|
||||||
|
echo "" > /etc/nginx/map-referrer.conf
|
||||||
|
fi
|
||||||
|
|
||||||
BLACKLIST="$(curl -s https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-referrers.list)"
|
BLACKLIST="$(curl -s https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-referrers.list)"
|
||||||
DATA=""
|
DATA=""
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|||||||
@ -1,24 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# replace pattern in file
|
if [ ! -f "/etc/nginx/map-user-agent.conf" ] ; then
|
||||||
function replace_in_file() {
|
echo "" > /etc/nginx/map-user-agent.conf
|
||||||
# escape slashes
|
fi
|
||||||
pattern=$(echo "$2" | sed "s/\//\\\\\//g")
|
|
||||||
replace=$(echo "$3" | sed "s/\//\\\\\//g")
|
|
||||||
replace=$(echo "$replace" | sed "s/\\ /\\\\ /g")
|
|
||||||
sed -i "s/$pattern/$replace/g" "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
BLACKLIST="$(curl -s https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-user-agents.list)"
|
BLACKLIST="$(curl -s https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/bad-user-agents.list)"
|
||||||
DATA=""
|
DATA=""
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for ua in $BLACKLIST ; do
|
for ua in $BLACKLIST ; do
|
||||||
DATA="${DATA}~*(?:\\\\b)${ua}\(?:\\\\b) yes;\n"
|
DATA="${DATA}~*(?:\\\\b)${ua}(?:\\\\b) yes;\n"
|
||||||
done
|
done
|
||||||
DATA_ESCAPED=$(echo "$DATA" | sed 's: :\\\\ :g' | sed 's:\\\\ yes;: yes;:g' | sed 's:\\\\\\ :\\\\ :g')
|
DATA_ESCAPED=$(echo "$DATA" | sed 's: :\\\\ :g' | sed 's:\\\\ yes;: yes;:g' | sed 's:\\\\\\ :\\\\ :g')
|
||||||
|
|
||||||
cp /opt/confs/global/map-user-agent.conf /etc/nginx/map-user-agent.conf
|
echo -e "map \$http_user_agent \$bad_user_agent { default no; $DATA_ESCAPED }" > /etc/nginx/map-user-agent.conf
|
||||||
replace_in_file "/etc/nginx/map-user-agent.conf" "%BLOCK_USER_AGENT%" "$DATA_ESCAPED"
|
|
||||||
cp /etc/nginx/map-user-agent.conf /cache
|
cp /etc/nginx/map-user-agent.conf /cache
|
||||||
|
|
||||||
if [ -f /tmp/nginx.pid ] ; then
|
if [ -f /tmp/nginx.pid ] ; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user