ตัวอย่างเช่นเราป้องกัน ไฟล์ phpinfo.php
Rule ที่เขียน ของ modsecurity
โค้ด: เลือกทั้งหมด
SecRule REQUEST_URI "@pm phpinfo.php" "phase:1,id:'10',log,deny,status:403"
โค้ด: เลือกทั้งหมด
nano /usr/local/directadmin/data/users/[user]/openlitespeed.conf
เช่น
[ur=/บทความ/91-hosting/2263-virtual-hosting-คืออะไร.htmll]virtualHost[/url] mindphp.com-443 {
...
}
เพิ่มโค้ดนี้ก่อนปิด } สุดท้ายของ virtualHost
ได้ผลตามตัวอย่าง
โค้ด: เลือกทั้งหมด
module mod_security {
modsecurity on
modsecurity_rules `
SecRuleEngine On
SecDebugLog /tmp/auditlog-debug.txt
SecDebugLogLevel 9
SecAuditLogParts AB
#SecAuditEngine On
#SecAuditLog /tmp/auditlog.txt
#SecAuditLogType Serial
SecAuditLogStorageDir /tmp/
SecRule REQUEST_URI "@pm phpinfo.php" "phase:1,id:'10',log,deny,status:403"
`
}
คำสั่ง Restart OpenLitespeed Web Server
โค้ด: เลือกทั้งหมด
service lsws restart
Access to this resource on the server is denied!
ตามภาพ