評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]
需求說明 使用 apache mod_evasive 模組限制網站瀏覽者 5分鐘內 瀏覽次數超過30次就給他503 ,10分鐘後解鎖。
- 安裝模組
sudo apt-get update
sudo apt-get install libapache2-mod-evasive
- 建立暫存檔存封鎖資料
sudo mkdir -p /var/log/mod_evasive
sudo chown www-data:www-data /var/log/mod_evasive
- 編輯設定檔
/etc/apache2/mods-available/evasive.conf
<IfModule mod_evasive20.c>
# 5 分鐘內(300秒)超過 30 次請求就封鎖
DOSHashTableSize 3097
DOSPageCount 30
DOSPageInterval 300
# 封鎖時間 10 分鐘(600 秒)
DOSBlockingPeriod 600
# 暫存檔案路徑
DOSLogDir "/var/log/mod_evasive"
# 回應 503 Service Unavailable
DOSEmailNotify you@example.com
</IfModule>
- 啟用模組 與 重啟服務
sudo a2enmod evasive
sudo systemctl restart apache2
- 測試
ab -n 50 -c 5 http://你的網站/
評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]