๐ง Handling BunnyCDN IP Blocked by Fail2Ban / iptables
๐ฏ Tujuan
Mengidentifikasi dan memperbaiki kondisi di mana IP BunnyCDN terblokir oleh:
-
iptables -
fail2ban
Yang menyebabkan:
-
โ CDN error 504 Gateway Timeout
-
โ Asset (CSS/JS) gagal load
๐งฉ Prasyarat
-
Akses root / sudo
-
File list IP Bunny:
bunny_ips.txt(api.bunny.net/system/edgeserverlist/plain)
๐ช STEP 1 โ Tambahkan IP Bunny ke file
Buat / update file:
nano bunny_ips.txt
Isi dengan IP Bunny (1 IP per baris):
89.187.188.227
89.187.188.228
...
๐ช STEP 2 โ Cek IP yang diblok oleh iptables
Gunakan command berikut:
for ip in $(cat bunny_ips.txt); do
sudo iptables -L -n -w | grep $ip && echo "BLOCKED: $ip"
done
๐ Catatan:
-
Gunakan
-wuntuk menghindari error:xtables lock
๐ช STEP 3 โ Cek IP yang diblok oleh Fail2Ban
sudo grep -f bunny_ips.txt /var/log/fail2ban.log > blocked-f2b.log
๐ Hasil:
-
file
blocked-f2b.logberisi IP yang pernah di-ban
๐ช STEP 4 โ Kumpulkan IP yang aktif terblokir di iptables
Dump rules:
sudo iptables -L -n -w > iptables_rules.txt
Filter IP Bunny:
grep -f bunny_ips.txt iptables_rules.txt > blocked-bunny-cdn.log
๐ช STEP 5 โ Unban IP dari Fail2Ban
Unban semua IP Bunny:
for ip in $(cat bunny_ips.txt); do
sudo fail2ban-client set apache-badbots unbanip $ip
done
๐ Jika ada jail lain, cek:
fail2ban-client status
๐ช STEP 6 โ Tambahkan IP ke whitelist Fail2Ban
Edit file:
nano /etc/fail2ban/jail.local
๐น Tambahkan di [apache-badbots] atau [DEFAULT]
Contoh:
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 104.45.64.239/32 \
89.187.188.227/32 \
89.187.188.228/32 \
...
๐ Tips:
-
Gunakan
\untuk multi-line -
Hindari 1 line terlalu panjang
๐ช STEP 7 โ Validasi konfigurasi Fail2Ban
sudo fail2ban-client -d
sudo fail2ban-client -t
๐ Pastikan:
-
tidak ada error config
๐ช STEP 8 โ Restart & Verifikasi Fail2Ban
sudo systemctl restart fail2ban
๐ Cek status:
sudo systemctl status fail2ban
sudo fail2ban-client status
sudo fail2ban-client status apache-badbots
๐งช STEP 9 โ Testing
Test via CDN:
curl -I https://cotecna-cdn.b-cdn.net/css/app.min.css
Expected:
HTTP/1.1 200 OK
๐จ Troubleshooting tambahan
โ Masih kena block?
Cek jail lain:
fail2ban-client status
โ Masih 504?
Cek:
-
Nginx log:
tail -f /var/log/nginx/error.log
-
Origin connectivity:
curl -I http://localhost
๐ก Best Practice (Highly Recommended)
โ 1. Jangan hanya pakai /32
Gunakan kombinasi:
-
/32โ IP spesifik -
/16โ range CDN
โ 2. Pertimbangkan disable badbots
sudo nano /etc/fail2ban/jail.local
[apache-badbots]
enabled = false
โ 3. CDN-aware security
Lebih baik:
-
proteksi bot di CDN (Bunny Shield / WAF)
-
bukan di origin
๐ฏ Kesimpulan
Checklist akhir:
-
โ IP Bunny tidak diblok iptables
-
โ IP Bunny tidak diban fail2ban
-
โ Sudah di whitelist
-
โ Fail2Ban sudah restart
-
โ CDN return 200 OK
๐ Bonus (Optional Automation)
Kalau mau otomatis:
awk '{print $1"/32 \\"}' bunny_ips.txt
๐ langsung jadi format ignoreip
Kalau mau, gue bisa bantu bikin:
-
script auto sync IP Bunny (cron)
-
atau integrasi dengan API Bunny biar gak manual lagi
No Comments