- Puanlar
- 4567
- Başarılar
- 8
- New
- #1
6.1. ModSecurity'yi Aktifleştir
Plesk panel üzerinden ModSecurity'yi aktif etmek için aşağıdaki adımları takip edin:
- Araçlar ve Ayarlar > ModSecurity menüsüne gidin
- "ModSecurity'i etkinleştir" seçeneğini işaretleyin
- "OWASP ModSecurity Core Rule Set" seçeneğini seçin
6.2. Özel ModSecurity Kuralları
Özel güvenlik kuralları eklemek için aşağıdaki dosyayı düzenleyebilirsiniz.
Dosya Konumu:
/etc/httpd/conf.d/mod_security_custom.conf(AlmaLinux)/etc/apache2/modsecurity-custom.conf(Ubuntu)
# =====================================================
# MODSECURITY - ÖZEL KURALLAR
# False Positive Engelleme ve Ek Korumalar
# =====================================================
<IfModule mod_security2.c>
# -------------------------------------------------
# TEMEL MOTOR AYARLARI
# -------------------------------------------------
SecRuleEngine On
SecRequestBodyAccess On
SecResponseBodyAccess Off
SecUploadDir /tmp/
SecUploadKeepFiles Off
# -------------------------------------------------
# VERİ LİMİTLERİ
# -------------------------------------------------
SecRequestBodyLimit 13107200
SecRequestBodyNoFilesLimit 131072
SecResponseBodyLimit 524288
# -------------------------------------------------
# LOG AYARLARI
# -------------------------------------------------
SecDebugLog /var/log/modsec_debug.log
SecDebugLogLevel 0
SecAuditEngine RelevantOnly
SecAuditLog /var/log/modsec_audit.log
SecAuditLogParts ABIJDEFHZ
# -------------------------------------------------
# WORDPRESS FALSE POSITIVE FIX'LERİ
# -------------------------------------------------
# WordPress admin-ajax için
SecRule REQUEST_URI "@contains /wp-admin/admin-ajax.php" \
"id:10001,phase:1,pass,nolog,ctl:ruleRemoveById=942100,ctl:ruleRemoveById=942190"
# WordPress login için
SecRule REQUEST_URI "@contains /wp-login.php" \
"id:10002,phase:1,pass,nolog,ctl:ruleRemoveById=942100,ctl:ruleRemoveById=942190"
# -------------------------------------------------
# POPÜLER EKLENTİLER İÇİN FIX'LER
# -------------------------------------------------
# Elementor
SecRule REQUEST_URI "@contains /wp-json/elementor" \
"id:10003,phase:1,pass,nolog,ctl:ruleRemoveById=942100"
# WooCommerce
SecRule REQUEST_URI "@contains /wc-api" \
"id:10004,phase:1,pass,nolog,ctl:ruleRemoveById=942100"
# -------------------------------------------------
# TEHLİKELİ DOSYA UZANTILARINI ENGELLE
# -------------------------------------------------
SecRule FILES_NAMES "\.(php|phtml|php3|php4|php5|php7|phar|pl|py|jsp|asp|aspx|sh|cgi|bash)$" \
"id:20001,phase:2,deny,status:403,msg:'Tehlikeli dosya yükleme engellendi'"
# -------------------------------------------------
# SQL INJECTION EK KURALLAR
# -------------------------------------------------
SecRule ARGS "@rx (union.*select.*from|select.*from.*where|insert.*into.*values|delete.*from|drop\s+table|create\s+table)" \
"id:30001,phase:2,deny,status:403,capture,msg:'SQL Injection tespit edildi'"
# -------------------------------------------------
# XSS KORUMASI
# -------------------------------------------------
SecRule ARGS "@rx (<script.*>|javascript:|onload=|onerror=|onclick=|onmouseover=)" \
"id:40001,phase:2,deny,status:403,msg:'XSS saldırısı tespit edildi'"
</IfModule>
6.3. ModSecurity'yi Yeniden Başlat
Yapılan değişikliklerin aktif olması için Apache servisini yeniden başlatın.
# Ubuntu
systemctl restart apache2
# AlmaLinux
systemctl restart httpd