Darknet engelleyicim için sadece bir Tor çıkış düğümü IO listesine ve aşağıdaki kurala ihtiyacım var:
location / {
limit_req zone=one; #request limit
limit_conn addr
include /etc/nginx/conf.d/tor-ips.conf; #tor ips blocken ...
}
Aşağıdaki script ile bir Ip kara listesi oluşturabilirim:
IP Güncelleme Komut Dosyası
#!/bin/sh
# Copyright 2012, Nico R. Wohlgemuth <nico@lifeisabug.com> WGET=/usr/bin/wget
LIST=/etc/nginx/conf.d/tor-ips.conf
#ziel der blacklist
LISTBAK=/etc/nginx/conf.d/tor-ips.bak
TEMPLIST=/tmp/torlist.txt
wget -qO- https://check.torproject.org/exit-addresses | grep ExitAddress | cut -d ' ' -f 2 | sed "s/^/deny /g; s/$/;/g" > $TEMPLIST
if [ ! -s $TMPTEMPLIST ]; then
echo "error: list is empty or was not downloaded"
exit 1
fi
head -n3 $TEMPLIST
tail -n3 $TEMPLIST
echo -e "\ndoes this look okay? [y/n]: "
read yesno
if [ $yesno != "y" ]; then
echo "error: aborted"
rm $TEMPLIST exit 2
else
mv $LIST $LISTBAK
mv $TEMPLIST $LIST
fi
/usr/sbin/nginx -t
if [ $? -ne 0 ]; then
echo "deine config ist kaputtt"
else
/bin/systemctl reload nginx
echo "alles ok"
fi
Komut dosyası “/etc/nginx/conf.d/” dizinine bir PI listesi (tor-ips.conf) yerleştirir. Sunucu yapılandırmasını kontrol eder ve Nginx ayarlarını günceller. Engellenen kullanıcılar daha sonra bunu görecektir:
