Corvinus
Active Member
- Joined
- Jan 3, 2025
- Topics
- 4
- Messages
- 17
- Reaction score
- 8
1. Arama Motorlarına Yalnızca İzin Verme Kuralı
Bu kural, yalnızca belirli arama motorlarının sitenize erişmesine izin verir (örneğin, Google, Bing, Yandex).
Code:
{ "expression": "(http.user_agent contains 'Googlebot') or (http.user_agent contains 'Bingbot') or (http.user_agent contains 'YandexBot')", "action": "allow", "description": "Allow only specific search engines", "priority": 1 }
2. Belirli Botları Engelleme Kuralı
Bu kural, kötü niyetli veya istenmeyen botları (örneğin, içerik çalan botlar) engeller.
Code:
{ "expression": "(http.user_agent contains 'AhrefsBot') or (http.user_agent contains 'SEMrushBot') or (http.user_agent contains 'MJ12bot') or (http.user_agent contains 'Scrapy')", "action": "block", "description": "Block unwanted SEO and scraper bots", "priority": 2 }
3. Sosyal Medya Trafiğini Engelleme veya İzin Verme Kuralı
Bu kural, sosyal medya platformlarından gelen trafiği kontrol eder.
Code:
{ "expression": "(http.referer contains 'facebook.com') or (http.referer contains 'instagram.com') or (http.referer contains 'twitter.com')", "action": "block", "description": "Block traffic from social media platforms", "priority": 3 }
4. Görsel Arama Motorlarını Engelleme
Bazı görsel arama motorlarının (örneğin TinEye) sitenizdeki görselleri indekslemesini engellemek için:
Code:
{ "expression": "(http.user_agent contains 'Googlebot-Image') or (http.user_agent contains 'bingbot') or (http.user_agent contains 'TinEye')", "action": "block", "description": "Block image search engines", "priority": 4 }
5. IP veya Ülke Bazlı Erişim Kontrolü
Belirli motorlara yalnızca belirli IP'lerden veya ülkelerden erişim izni verin.
Code:
{ "expression": "(ip.src in { '66.249.64.0/19', '157.55.39.0/24' })", "action": "allow", "description": "Allow only specific IP ranges (Googlebot and Bingbot)", "priority": 5 }
6. Bot Yönetimi - Davranışsal Analiz
Cloudflare'ın Bot Yönetimi özelliğiyle belirli davranış kalıplarına dayalı kötü botları engelleyin.
Code:
{ "expression": "(cf.bot_management.verified_bot ne true)", "action": "challenge", "description": "Challenge unverified bots", "priority": 7 }
7. Genel Kötü Niyetli Trafik Engelleme
Belirli kötü niyetli kullanıcı ajanlarını engellemek için:
Code:
{ "expression": "(http.user_agent contains 'curl') or (http.user_agent contains 'wget') or (http.user_agent contains 'python-requests') or (http.user_agent contains 'libwww-perl')", "action": "block", "description": "Block malicious user agents", "priority": 8 }
8. Otomatik Güncellemeler için Script
Cloudflare API kullanarak bu kuralları otomatik olarak güncellemek için bir Python script'i yazabilirsiniz:
Code:
import requests API_TOKEN = "CLOUDFLARE_API_TOKEN" ZONE_ID = "YOUR_ZONE_ID" headers = { "Authorization": f"Bearer {API_TOKEN}", "Content-Type": "application/json" } rule_payload = { "expression": "(http.user_agent contains 'AhrefsBot') or (http.user_agent contains 'SEMrushBot')", "action": "block", "description": "Block unwanted bots" } response = requests.post( f"https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/firewall/rules", json=rule_payload, headers=headers ) if response.status_code == 200: print("Rule successfully updated!") else: print(f"Failed to update rule: {response.status_code} - {response.text}")