#!/bin/sh
NGINX_CONF=путь до конфига
MAIL="" # true is enable send mail
MAILTO=root
LA_ACTIVATE=900
LA_DEACTIVATE=600
NGINX_CONNECT=1024
########################################################
TMPLOG=/tmp/testcookie_module.tmp
NGINXCONN=`curl -s https://сайта/nginx-status | grep "Active" | awk '{print($3)}'`
LA=`cat /proc/loadavg | awk -F '.' '{print($1)}'`
function e {
echo -en $(date "+%F %T"): "$1"
}
if [ ! -f $TMPLOG ];then echo 0 > $TMPLOG; fi
LASTRESULT=`cat $TMPLOG`
if [ -n "$NGINXCONN" ]; then
if [ $NGINXCONN -gt $NGINX_CONNECT ]; then
ALERT1="1"
fi
fi
if [ -n "$LA" ]; then
if [ $LA -gt $LA_ACTIVATE ]; then
ALERT2="1"
fi
fi
ALERT=$ALERT1$ALERT2
if [ -n "$ALERT" -a $LASTRESULT -eq 0 ]; then
e; printf "Nginx connect: %-4s LA: %-3s | Activate testcookie\n" "$NGINXCONN" "$LA"
sed -i 's/.*##-AUTO-DDOS-LABEL-##/\ttestcookie on; ##-AUTO-DDOS-LABEL-##/g' $NGINX_CONF
/sbin/service nginx reload >/dev/null 2>&1
echo 1 > $TMPLOG
if [ "$MAIL" = "true" ];then
echo "Nginx connect $NGINXCONN, LA $LA. Nginx test-cookie enable" | mail -s "`hostname` DDOS detected. Nginx test-cookie enable" $MAILTO
fi
fi
if [ $LA -le $LA_DEACTIVATE -a $LASTRESULT -eq 1 ]; then
e; printf "Nginx connect: %-4s LA: %-3s | Dectivate testcookie\n" "$NGINXCONN" "$LA"
sed -i 's/.*##-AUTO-DDOS-LABEL-##/\ttestcookie off; ##-AUTO-DDOS-LABEL-##/g' $NGINX_CONF
/sbin/service nginx reload >/dev/null 2>&1
echo 0 > $TMPLOG
fi
И как
location.href = 'ссылка из json' ?)