サーバー管理 · 1 min read · Dec 16, 2025

専用のWeb & MySQL、メール & DNSサーバーを備えた仮想マルチサーバー環境 - Debian Squeeze と ISPConfig 3 - ページ 5

7.2.7 fail2ban のインストール

falko が The Perfect Server - Debian Squeeze (Debian 6.0) With BIND & Courier [ISPConfig 3] で提案している jail.local ファイルを拡張します: /etc/fail2ban/jail.local

nano /etc/fail2ban/jail.local

以下を追加または編集する必要があります:

[roundcube]  
enabled  = true  
port     = http  
filter   = roundcube  
logpath  = /var/log/roundcube/userlogins  
maxretry = 5

最後に(非常に重要)、/etc/fail2ban/filter.d/roundcube.conf ファイルを作成することを忘れないでください。

nano /etc/fail2ban/filter.d/roundcube.conf

以下の内容で:

[Definition]
failregex = FAILED login for .*. from 
ignoreregex =

fail2ban を再起動します:

/etc/init.d/fail2ban restart

すべての監視がアクティブであることを確認するには、次のコマンドを使用します:

iptables -L -n 

7.2.8 fail2ban サポート付き mod_evasive のインストール

mod_evasive は DDoS 攻撃を処理するための Apache モジュールです。これをインストールし、fail2ban を構成して報告された攻撃を自動的に禁止/解除します。

apt-get install libapache2-mod-evasive
mkdir /var/lock/mod-evasive
chown www-data /var/lock/mod-evasive
ln -s /etc/alternatives/mail /bin/mail
nano /etc/apache2/mods-available/mod-evasive.conf

そして貼り付けます:


   DOSHashTableSize 3097
   DOSPageCount 3
   DOSSiteCount 60
   DOSPageInterval 1
   DOSSiteInterval 2
   DOSBlockingPeriod 15
   DOSEmailNotify [email protected]
   DOSLogDir "/var/lock/mod_evasive"

その後、モジュールを有効にし、apache を再起動します

a2enmod mod-evasive
/etc/init.d/apache2 restart

mod_evasive は DDoS 攻撃を検出しません。IPTables で禁止するには、次のファイルを作成する必要があります: /etc/fail2ban/filter.d/apache-dosevasive.conf:

# Fail2Ban configuration file
#
# Author: Xela
#
# $Revision: 728 $
#
[Definition]

# Option:  failregex
# Notes.:  regex to match the Forbidden log entrys in apache error.log
#          maybe (but not only) provided by mod_evasive
#
# Values:  TEXT
#
failregex = ^\[[^\]]*\]\s+\[error\]\s+\[client \] client denied by server configuration:\s

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =

そして /etc/fail2ban/jail.local に次を追加します:

[apache-dosevasive]

enabled = true
filter  = apache-dosevasive
action = iptables-allports[name=dos]
logpath = /var/log/apache*/*error.log
bantime = 600
maxretry = 10

7.3 メールサーバーの拡張

7.3.1 強化されたメール SPAM 保護

以下のコマンドは、ISPConfig 3 サーバー上の postfix に対してより厳格な SPAM 処理を有効にします。

postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_recipient_domain, reject_non_fqdn_recipient, reject_unauth_destination, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_rbl_client cbl.abuseat.org,reject_rbl_client dul.dnsbl.sorbs.net,reject_rbl_client ix.dnsbl.manitu.net, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination'

その後、postfix を再起動します:

/etc/init.d/postfix restart

7.3.2 Postgrey のインストール

Postgrey は、受信するすべてのスパムメールの 99% を排除します。これをインストールするには、次のコマンドを実行します:

apt-get install postgrey
/etc/init.d/postgrey start

Postfix の設定ファイルは /etc/postfix にあります。/etc/postfix/main.cf を編集し、smtpd_recipient_restrictions に check_policy_service inet:127.0.0.1:60000 を追加します。

その後、postfix の設定を再読み込みします:

postfix reload

7.4 SSL を使用してサーバーを保護する

最後に、次のチュートリアルに従うべきです: https://www.howtoforge.com/securing-your-ispconfig-3-installation-with-a-free-class1-ssl-certificate-from-startssl. 正しいサーバーでコマンドを実行することを忘れないでください!

8 サーバーの維持

サーバーを最新の状態に保つために、定期的にこれを実行する必要があります:

apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade

9 リンク/クレジット/ソース

ほとんどが私からのものではないので、このチュートリアルで使用したすべてのリンクを以下に示します:

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。