fix referrers script
This commit is contained in:
parent
3a7aa5d9c0
commit
ed8bd902b1
@ -1,14 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# replace pattern in file
|
|
||||||
function replace_in_file() {
|
|
||||||
# escape slashes
|
|
||||||
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-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'
|
||||||
@ -16,8 +7,7 @@ for ref in $BLACKLIST ; do
|
|||||||
DATA="${DATA}\"~${ref}\" yes;\n"
|
DATA="${DATA}\"~${ref}\" yes;\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
cp /opt/confs/global/map-referrer.conf /etc/nginx/map-referrer.conf
|
echo "map \$http_referer \$bad_referrer { hostnames; default no; $DATA }" > /etc/nginx/map-referrer.conf
|
||||||
replace_in_file "/etc/nginx/map-referrer.conf" "%BLOCK_REFERRER%" "$DATA"
|
|
||||||
cp /etc/nginx/map-referrer.conf /cache
|
cp /etc/nginx/map-referrer.conf /cache
|
||||||
|
|
||||||
if [ -f /tmp/nginx.pid ] ; then
|
if [ -f /tmp/nginx.pid ] ; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user