GNU/Linux >> Linux の 問題 >  >> Panels >> Panels

CentOS5.1でVirtualminを使用した仮想ホスティングの方法

CentOS5.1でのVirtualminを使用した仮想ホスティングの方法

バージョン1.0.1
作成者:Andrew Colin Kissa

はじめに

このチュートリアルでは、仮想Webホスティング業者が必要とするすべてのサービスを提供するようにCentOS5.xサーバーを設定する方法を示します。これらには、Webホスティング、(SMTP-AUTHおよびTLS、SPF、DKIM、ドメインキー)を備えたSMTPサーバー、DNS、FTP、MySQL、POP3 / IMAP、ファイアウォール、統計用Webalizerが含まれます。

次のソフトウェアを使用します:

  • データベースサーバー:MySQL 5.0.22
  • メールサーバー:Postfix 2.3.3
  • NSサーバー:BIND9 9.3.3
  • Webサーバー:Apache 2.2.3 /PHP 5.1.6
  • FTPサーバー:Vsftpd 2.0.5
  • POP3 / IMAPサーバー:Dovecot 1.0
  • Webalizer:サイト統計2.01_10用
  • Virtualmin:コントロールパネル

OSのインストール

要件

システムをインストールするには、

が必要です。
  • CentOS5.1インストールメディア
  • 良好なインターネット接続

ベースシステムをインストールする

インストールの一部の段階は、ハウツーを短くするためにここでは説明されていません。たとえば、grubの構成段階は省略されています。

  • DVDまたはCDメディアから起動し、起動プロンプトでlinuxtextと入力します。
  • メディアテストをスキップします。
  • 言語を選択してください:

  • キーボードレイアウトの選択:

  • ネットワークを構成します。静的エントリを使用できるdhcpがない場合は、dhcpを使用します。

  • [はい]を選択してドライブを初期化します:

  • パーティショニングタイプのカスタムレイアウトを選択します:

  • パーティションを作成する:

  • ネットワーキングの構成:

IPアドレスとネットマスクを設定します:

ゲートウェイとdnsサーバーを設定します:

ホスト名を設定します:

  • タイムゾーンを設定します:

  • ルートパスワードを設定します:

  • サーバーグループを選択し、ソフトウェア選択のカスタマイズを選択します:

  • パッケージグループは次のように選択します:
    • DNSネームサーバー
      • bind-chroot

  • 編集者
    • vimで強化された
  • FTPサーバー
  • メールサーバー
    • 鳩小屋
    • spamassassin
    • 接尾辞

  • Mysqlデータベース
    • mysql-server

  • Webサーバー
    • mod_ssl
    • ウェバライザー
    • php
    • php-pear
    • http-suexec
    • php-mysql

インストールを開始します:

ファイルシステムのフォーマット:

インストールが実行されます:

システムを再起動します:

CentOS5.1でのVirtualminを使用した仮想ホスティングの方法-2ページ

無効にするサービス

システムのセキュリティを強化し、システムリソースを解放するには、不要なサービスを無効にする必要があります。このスクリプトを実行して、これを行うことができます。

  • acpid
  • anacron
  • apmd
  • autofs
  • Bluetooth
  • カップ
  • firstboot
  • gpm
  • ハルデーモン
  • メッセージバス
  • mdmonitor
  • 隠し
  • ip6tables
  • クズ
  • lvm2-monitor
  • netfs
  • nfslock
  • pcscd
  • ポートマップ
  • rpcgssd
  • rpcidmapd
  • sendmail
  • smartd
  • yum-updatesd

基本

システムを構成する準備をするために、いくつかの問題を修正する必要があります。

  • アップデートをインストールする

yumアップグレード

  • mtaを接尾辞に切り替えます

代替案--configmta

'mta'を提供する2つのプログラムがあります。
選択コマンド
------------------------------ -----------------
1 /usr/sbin/sendmail.postfix
* + 2 /usr/sbin/sendmail.sendmail
Enter現在の選択を維持するには[+]、または選択番号を入力します:1

  • cache-nameserver configのインストール:

yum install cache-nameserver

  • ビルドツールのインストール:

yum install gcc cpp gcc-c ++ automake automake14 automake15 automake16 automake17 openssl-devel subversion ncurses-devel -y

ネットワークエイリアスの構成

cp / etc / sysconfig / network-scripts / ifcfg-eth0 / etc / sysconfig / network-scripts / ifcfg-eth0:1

ファイル/etc/ sysconfig / network-scripts / ifcfg-eth0:1を次のように変更します。
 DEVICE =eth0:1BOOTPROTO =staticBROADCAST =192.168.1.255IPADDR =192.168.1.6NETMASK =255.255.255.0NETWORK=192.168。 1.0ONBOOT=はい

Webmin/Virtualminをインストール

  • webmin pgpキーのインポート:

wget http://www.webmin.com/jcameron-key.asc
rpm --import jcameron-key.asc

  • rpmをダウンロードします:

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.390-1.noarch.rpm

  • rpmを確認します([OK]と言うか、もう一度ダウンロードする必要があります):

rpm --checksig webmin-1.390-1.noarch.rpm

  • rpmをインストールします:

rpm -Uvh webmin-1.390-1.noarch.rpm

初期Webmin構成

/etc/webmin/miniserv.confを編集してwebminを保護し、次の変更を加える必要があります。

  • SSLのみを使用する:
 ssl =1 
  • ポートを443に変更し、2番目のNICにのみバインドします:
 port =443bind =192.168.1.6 
  • UDPブロードキャストを無効にする:
#listen =10000 
  • ログイン失敗時のホストロックアウトを3に変更:
 blockhost_failures =3 
  • ホストのロックアウトタイムアウトを120に増やします:
 blockhost_time =120 
  • ログイン失敗時のユーザーロックアウトを3に変更します:
 blockuser_failures =3 
  • ユーザーロックアウトのタイムアウトを120に変更します:
 blockuser_time =120 
  • レルムを別のものに変更します:
 realm =cpanel 
  • utmpへのログインを記録します:
 utmp =1 

webmin Tigerテーマをインストールします:

  • rootとパスワードを使用してhttps://192.168.1.5:10000経由でwebminにログインします。
  • webminに移動しますか?構成 ? webminテーマ。
  • [ftpまたはhttpURLから]を選択し、http://www.stress-free.co.nz/files/theme-stressfree.tar.gzと入力します
  • [テーマのインストール]をクリックします。
  • [テーマを一覧表示するには戻る]をクリックします。
  • 現在のテーマとしてStressFreeを選択し、[変更]をクリックします。

php-pearモジュールをインストールします:

  • webminに移動しますか? webmin構成? webminモジュール。
  • からサードパーティモジュールを選択し、http://www.webmin.com/download/modules/php-pear.wbm.gzと入力します。
  • [モジュールのインストール]をクリックします。

virtualminをインストールします:

  • webminに移動しますか? webmin構成? webminモジュール。
  • ftpまたはhttpURLからインストールを選択し、http://download.webmin.com/download/virtualmin/virtual-server-3.51.gpl.wbm.gzと入力します
  • [モジュールのインストール]をクリックします。

不要なモジュールを削除するwebminに移動しますか? webmin構成?以下を削除して選択します:

  • ADSLクライアント
  • Baculaバックアップシステム
  • CDバーナー
  • CVSサーバー
  • クラスター変更パスワード
  • クラスターコピーファイル
  • クラスターcronジョブ
  • クラスターシェルコマンド
  • クラスターソフトウェアパッケージ
  • クラスターuserminサーバー
  • クラスターユーザーとグループ
  • クラスターwebminサーバー
  • コマンドシェル
  • 構成エンジン
  • カスタムコマンド
  • DHCPサーバー
  • Fetchmailメールの取得
  • ファイルマネージャー
  • Froxftpプロキシ
  • HTTPトンネル
  • 心拍モニター
  • IPsec VPN
  • JabberIMサーバー
  • LDAPサーバー
  • 論理ボリューム管理
  • Majordomoリストマネージャー
  • NFSエクスポート
  • NISクライアントとサーバー
  • OpenSLPサーバー
  • PPPダイヤルインサーバー
  • PPPダイヤルアップクライアント
  • PPTPVPNサーバー
  • PPTPVPNクライアント
  • Postgresqlデータベースサーバー
  • プリンター管理者
  • ProFTPDサーバー
  • QMAILメールサーバー
  • SMARTドライブのステータス
  • SSH/Telnetログイン
  • SSLトンネル
  • SAMBAWindowsファイル共有
  • スケジュールされたコマンド
  • Sendmailメールサーバー
  • ショアラインファイアウォール
  • イカ分析レポートジェネレーター
  • Squidプロキシサーバー
  • 音声メールサーバー
  • WU-FTPサーバー
  • Idmapdサーバー

webminを再起動します:

 service webmin restart 

Rpmforgeリポジトリを構成する

rpm -Uhv http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

注:別のアーキテクチャを使用している場合は、https://rpmrepo.org/RPMforge/Using for the right rpmを確認してください。
  • リポジトリを無効にします(ベースパッケージが上書きされないようにします)/etc/yum.d/rpmforge.repoを編集し、次のオプションを設定します:
 enabled =0 

追加の必要なパッケージをインストールする
  • clamavをインストールします:

yum --enablerepo =rpmforge install clamav clamav-db clamav-milter clamd -y
wget http://www.topdog-software.com/files/clamav-milter.patch
patch / etc / init .d / clamav-milter chkconfig --del clamd
freshclam

  • 健全なセキュリティ署名をインストールする:

wget http://www.sanesecurity.co.uk/clamav/update_sanesecurity.txt -O /usr/local/bin/update_sanesecurity.sh
chmod + x /usr/local/bin/update_sanesecurity.sh
ln -s /usr/local/bin/update_sanesecurity.sh /etc/cron.hourly/
/usr/local/bin/update_sanesecurity.sh

  • PHPアクセラレータのインストール:

yum --enablerepo =rpmforge install php-eaccelerator

  • rpmforgeから新しいspamassassinパッケージをインストールします:

yum --enablerepo =rpmforge upgrade spamassassin

  • spamass-milterをインストールします:

yum --enablerepo =rpmforge install spamass-milter

  • spamassassinに必要なperlモジュールをインストールします:

perl -MCPAN -e'Install Mail ::SPF'
perl -MCPAN -e'install Mail ::SPF ::Query'
perl -MCPAN -e'install Net ::Identity'
perl -MCPAN-e'インストールIP::Country ::Fast'
perl -MCPAN -e'install Mail ::DomainKeys'
perl -MCPAN -e'install Mail ::DKIM'

  • fuzzyOCRをインストールします:

yum --enablerepo =rpmforge install netpbm-progs ocrad gocr gifsicle giflib-utils giflib -y
svn co https://svn.own-hero.net/fuzzyocr/trunk/devel/
cd devel /
perl -MCPAN -e'install String ::About'
perl -MCPAN -e'install Time ::HiRes'
perl -MCPAN -e'install Log ::Agent'

cp -rv {FuzzyOcr.cf、FuzzyOcr.scansets、FuzzyOcr.preps、FuzzyOcr.pm、FuzzyOcr.words、FuzzyOcr /} /etc/mail/spamassassin
chcon -R system_u:object_r: etc_mail_t /etc/mail/spamassassin/{FuzzyOcr.cf,FuzzyOcr.scansets,FuzzyOcr.preps,FuzzyOcr.pm,FuzzyOcr.words,FuzzyOcr/}
wget http://www.gbnetwork.co.uk/mailscanner /FuzzyOcr.words -O /etc/mail/spamassassin/FuzzyOcr.words

  • Razorのインストール:

yum --enablerepo =rpmforge install razor-agents -y

  • roundcubeをインストールします:

yum install php-imap
rpm -Uvh http://www.topdog-software.com/oss/roundcube/roundcube-0.1-rc2.noarch.rpm

  • imapproxyをインストールします:

wget http://imapproxy.org/downloads/up-imapproxy-1.2.6.tar.gz
rpmbuild -tb up-imapproxy-1.2.6.tar.gz
rpm -Uvh / usr / src / redhat / RPMS / i386 / up-imapproxy-1.2.6-1.i386.rpm

  • サービスをアクティブ化する:

chkconfig --level 345 httpd on
chkconfig --level 345 postfix on
chkconfig --level 345 spamassassin on
chkconfig --level 345 spamass-milter on
chkconfig --level 345 clamav-milter on
chkconfig --level 345 mysqld on
chkconfig --level 345 named on
chkconfig --level 345 vsftpd on
chkconfig --level 345 dovecot on
chkconfig --level 345 imapproxy on

CentOS5.1でのVirtualminを使用した仮想ホスティングの方法-3ページ

構成 Postfixの設定 はじめに

次の機能を使用して接尾辞を設定します。

  • 仮想ホスティング
  • UCE防止
  • アンチウイルス
  • SMTP認証
  • TLS
  • RBL
  • SPF
  • 攻撃の軽減

アカウントとドメインの追加は、手動で行うこともできますが、virtualminを介して構成されます。セットアップはリソースに優しいように設計されているため、仕様が過剰でないマシンで実行できるため、リソースをより有効に活用できます。リソースを使いやすくするために、他のほとんどのハウツーのように外部データベースを使用して仮想ユーザー情報を保存したり、amavisd-newを実行するのではなく、スパムやウイルスのチェックにmilterを使用したりしていません。

基本

まず、ホスト名、メールの発信元、ネットワーク、ハッシュマップのスプールディレクトリなどの基本を構成します。特に明記されていない限り、これらの設定オプションはすべて/etc/postfix/main.cfに追加する必要があります。サンプル構成ファイルは、このページの最後からダウンロードできます。

 command_directory =/ usr / sbindaemon_directory =/ usr / libexec / postfixmydomain =example.commyorigin =$ mydomainmynetworks =127.0.0.0/8alias_maps =hash:/ etc / aliaselias_database =hash:/ etc / aliasescanonical_maps =hash:/ etc / postfix / canonicalsender_canonical_maps =hash:/ etc / postfix / canonicalrecipient_canonical_maps =hash:/ etc / postfix / canonicalvirtual_alias_maps =hash:/ etc / postfix / virtualmail_spool_directory =/ var / spool / mail 

Maildir

デフォルトのmbox形式ではなく、大幅に改善されたmaildir形式を使用します:

 home_mailbox =Maildir / 

SASL

SMTP認証を実行するには、SASLを使用しますが、saslauthdデーモンを実行する必要があるため、Cyrus SASLは使用しません。代わりに、Dovecot saslを使用します。これは、IMAPおよびPOP3に対してdovecotを実行するため、1つで2羽の鳥を殺すためです。石。

 smtpd_sasl_type =dovecotsmtpd_sasl_path =private / authsmtpd_sasl_auth_enable =yes 

TLS

SMTP認証中にプレーンテキストのパスワードがネットワーク経由で送信されないようにするためにTLSが必要です。TLSをサポートするサーバーは、セキュリティで保護された接続を介してこのサーバーと通信することもできます。

cacert.orgによって署名されたサーバー証明書を作成する手順については、こちらをご覧ください。

  • TLSランダムソースを設定します:
 tls_random_source =dev:/ dev / urandom 
  • サーバーTLSを有効にする:
 smtpd_use_tls =yessmtpd_tls_key_file =/etc/pki/postfix/key.pemsmtpd_tls_cert_file =/etc/pki/postfix/server.pemsmtpd_tls_CAfile =/etc/pki/postfix/root.crtsmtpd_tls_loglevel =1smtpd_ / spool / postfix / smtpd_tls_cache 
  • クライアントTLSを有効にする:
 smtp_use_tls =yessmtp_tls_key_file =/etc/pki/postfix/key.pemsmtp_tls_cert_file =/etc/pki/postfix/server.pemsmtp_tls_CAfile =/etc/pki/postfix/root.crtsmtp_tls_session_cache_database =btree =はい

スパム防止
  • 有効なEHLO/HELOが必要です:
smtpd_helo_required=はい
  • メールアドレスの収集攻撃を防ぐ:
 disable_vrfy_command =yes 
  • 拒否コードを永続的なものに変更します(デフォルトでは、postfixは4xxエラーコードを発行します。これは一時的な障害を意味し、永続的なエラーには5xxが必要です):
 unverified_recipient_reject_code =550unverified_sender_reject_code =550unknown_local_recipient_reject_code =550 
  • 送信者アドレスの確認を設定します:
 address_verify_map =btree:/ var / spool / postfix / verifysmtpd_sender_restrictions =hash:/ etc / postfix / sender_access 
  • / etc / postfix / sender_accessを作成して追加します:
 #sample /etc/postfix/sender_accessには、頻繁にスプーフィングされたドメインが含まれています 
  • ゾンビや壊れたクライアントからの攻撃を軽減します:
 smtpd_error_sleep_time =5ssmtpd_soft_error_limit =10smtpd_hard_error_limit =20 
  • 認証されたクライアントからのパイプライン処理のみを許可する:
 smtpd_data_restrictions =reject_unauth_pipelining 
  • postfix-policyd-spf-perlをインストールし、SPFサポートを有効にします:

wget http://www.openspf.org/blobs/postfix-policyd-spf-perl-2.005.tar.gz
tar xzvf postfix-policyd-spf-perl-2.005.tar.gz
cd postfix-policyd-spf-perl-2.005
cp postfix-policyd-spf-perl / etc / postfix /

これを/etc/postfix/master.cfに追加します:

 spfpolicy unix --n n --- spawn user =nobody argv =/ usr / bin / perl / etc / postfix / postfix-policyd-spf-perl 
  • DKIMサポートを追加する:

DKIMサポートを追加する手順については、こちらをご覧ください。

  • ドメインキーのサポートを追加する:

ドメインキーのサポートを追加する手順については、こちらをご覧ください。

  • すべてを機能させるには、smtpd_recipient_restrictionsオプションに依存するため、以下に設定します。
smtpd_recipient_restrictions =permit_mynetworks permit_sasl_authenticated reject_unauth_destination check_recipient_access hash:/etc/postfix/access reject_unknown_recipient_domain reject_unknown_sender_domain reject_unverified_recipient reject_non_fqdn_recipient reject_non_fqdn_sender reject_invalid_hostname reject_rbl_client list.dsbl.org reject_rbl_client zen.spamhaus.org reject_rbl_client l1.spews.dnsbl.sorbs.net reject_rbl_client combined.njabl. org subject_rbl_client bl.spamcop.net subject_rhsbl_sender dsn.rfc-ignorant.org subject_rhsbl_sender bogusmx.rfc-ignorant.org subject_rhsbl_sender rhsbl.sorbs.net subject_rhsbl_client dsn.rfc-ignorant.org subject_rhsbl_client bogus net check_policy_service unix:private / spfpolicy 

ミルター[SpamAssassin&ClamAV]

spamassassinを使用したスパム分類とclamavを使用したウイルススキャンでは、リソースを大量に消費するamavisd-newデーモンを使用する代わりに、postfixのmilterインターフェースを使用します。 clamdを実行する必要がないため、これは非常に効率的な方法です。clamavmilterがスキャン自体を実行します。

 smtpd_milters =unix:/var/clamav/clmilter.socket unix:/var/run/spamass.socknon_smtpd_milters =unix:/var/clamav/clmilter.socket unix:/var/run/spamass.sock 

DBファイルの作成

postmap / etc / postfix / canonical
postmap / etc / postfix / access
postmap / etc / postfix / virtual
postmap / etc / postfix / sender_access

サンプル構成ファイル
  • main.cf
  • master.cf
  • 正規
  • 仮想

CentOS5.1でのVirtualminを使用した仮想ホスティングの方法-4ページ

Dovecotのセットアップ はじめに

これにより、dovecotがIMAP/POP3サーバーとしてセットアップされます。

基本構成

IMAPとPOP3用にdovecotをセットアップし、SSLを無効にします。

 protocols =imap pop3listen =* ssl_listen =* ssl_disable =yes 

Maildir

デフォルトのmbox形式ではなく、maildir形式を使用します。

 mail_location =maildir:〜/ Maildir 

認証とSASL

多くのMSクライアントは暗号化された認証メカニズムを使用できないため、認証メカニズムとしてLOGINとPLAINを使用するようにdovecotを構成します。また、postfixがdovecotを使用してSMTP接続を認証できるようにSASLソケットを設定します。

 auth default {mechanisms =plain login passdb pam {} userdb passwd {} socket listen {client {path =/ var / spool / postfix / private / auth mode =0660 user =postfix group =postfix}}} 
>

クライアントの問題

Outlookファミリの一部のMSimapクライアントは、IMAPとPOP3の両方の実装に問題があるため、これらの回避策を設定してそれらに対応する必要があります。

 protocol imap {imap_client_workarounds =outlook-idle delay-newmail} protocol pop3 {pop3_client_workarounds =outlook-no-nuls oe-ns-eoh} 

プロキシの背後でIMAPを実行

imapサーバーはポート10143で実行するように構成されているため、ポート143はimapプロキシサーバーによって処理され、imapサーバーへの接続をキャッシュすることでWebメールのパフォーマンスが向上します。プロトコルのリッスンオプションはこれを設定します。

 protocol imap {imap_client_workarounds =outlook-idle delay-newmail listen =127.0.0.1:10143} 

サンプルファイル
  • dovecot.conf

Imapプロキシの設定

はじめに

imapproxyは、IMAPサーバーへの永続的な接続を維持できないWebメールクライアントを補うために作成されました。ほとんどのWebメールクライアントは、ほぼすべてのトランザクションでIMAPサーバーにログインする必要があります。この動作は、IMAPサーバーで悲劇的なパフォーマンスの問題を引き起こす可能性があります。 imapproxyは、Webメールクライアントがログアウトした後、サーバー接続を短時間開いたままにして、この問題に対処しようとします。ウェブメールクライアントが再び接続すると、imapproxyはキャッシュされた接続が利用可能かどうかを判断し、可能であればそれを再利用します。 --imapproxyのWebサイトによると。

構成

ファイル/etc/imapproxy.confに次の変更を加えます。

 server_hostname 127.0.0.1cache_size 3072listen_port 143server_port 10143cache_expiration_time 900proc_username nobodyproc_groupname nobodystat_filename /var/run/pimpstatsprotocol_log_filename / var / log / imapproxy_protocol.logsyslog_facility nofore_protocol.logsyslog_facility LOG_MAILsend_cp 

サンプルファイル
  • imapproxy.conf

バインド設定 はじめに

バインドはセキュリティを向上させるためにchrootで設定され、dnsサーバーの悪用を防ぐためにビューも使用します。

基本構成

基本構成では、デフォルトで再帰クエリとゾーン転送が無効になっています。また、スクリプトキディによるゼロデイ脆弱性に見舞われないように、実行しているBINDのバージョンを不明瞭にします。

options{ディレクトリ"/var / named"; pidファイル"/var/run/named/named.pid";リッスンオン{127.0.0.1; 192.168.1.5; };バージョン「ただ推測する」; allow-recursion {"localhost"; }; allow-transfer {"none"; };}; 

ロギング

ロギングは、ログに表示される煩わしい「lame-server」を削除してエラーを更新するようにカスタマイズされています。

 logging {category update {null; };カテゴリ更新-セキュリティ{null; };カテゴリlame-servers{null; };}; 

Chroot

これがファイル/etc/ sysconfig / namedに設定されていることを確認してください(通常はbind-chrootパッケージによって設定されます):

 ROOTDIR =/ var / named / chroot 

ポイントサーバー

マシンにDNS解決のためにこのサーバーを使用させます/etc/resolv.confを編集し、追加します:

 nameserver 127.0.0.1 

サンプルファイル
  • named.conf
  • / etc / sysconfig / named

Vsftpdセットアップ

はじめに

ftpサーバーとしてvsftpdを使用します。これは、proftpdおよびwuftpdサーバーとは対照的に優れた実績があります。

基本設定

基本的な設定では、匿名ユーザーを無効にし、ローカルシステムユーザーがftpサーバーに接続できるようにします。

 anonymous_enable =NOlocal_enable =YESwrite_enable =YESlocal_umask =022anon_upload_enable =NOanon_mkdir_write_enable =NOdirmessage_enable =YESxferlog_enable =YESconnect_from_port_20 =YESxferlog_file =/ var / log / vsftpd.logxferlog_std_format =YESftp_ 

Chroot

すべてのユーザーはホームディレクトリ(/ etc / vsftpd / chroot_listファイルのユーザー名を除く)にchrootされます。つまり、他のユーザーファイルを分割して表示することはできません。

 chroot_list_enable =YESchroot_local_user =YESchroot_list_file =/ etc / vsftpd / chroot_list 

禁止されたユーザー

ファイル/etc/ vsftpd / user_listに追加されたユーザーは、ログインできなくなります:

 userlist_enable =YES 

サンプルファイル
  • vsftpd.conf
  • user_list
  • chroot_list

CentOS5.1でのVirtualminを使用した仮想ホスティングの方法-5ページ

ClamavMilterのセットアップ

  • / etc / sysconfig / clamav-milterを編集します:
 CLAMAV_FLAGS ="--config-file =/ etc / clamd.conf --force-scan --local --max-children =5 --sendmail-cf =--outgoing --quiet" SOCKET_ADDRESS ="local :/var/clamav/clmilter.socket "
  • initファイルをパッチして、ソケットのアクセス許可を修正します:

wget http://www.topdog-software.com/files/clamav-milter.patch
patch /etc/init.d/clamav-milter

MySQLセットアップ

基本構成
  • ローカルホストのみをリッスンし、mysqldセクションで/etc/my.cnfを編集します。
 bind-address =127.0.0.1 

ルートパスワードの設定
  • ルートパスワードを設定します:

service mysqld start
mysqladmin -u root password NEWPASSWORD

SpamAssassinのセットアップ

基本構成
 required_hits 5report_safe 0rewrite_header Subject [SPAM] 

MySQLデータベースの作成
  • データベースを作成します:

mysqladmin -p create bayes

  • データベースにデータを入力します:

mysql -p bayes

  • ユーザーを作成します:

mysql -p
mysql> GRANT ALLONbayes。*[email protected] IDENTIFIED BY'password';

DBを使用するように構成する

  • ファイル/etc/mail/spamassassin/local.cfを編集して、次を追加します。
 bayes_store_module Mail ::SpamAssassin ::BayesStore ::MySQLbayes_sql_dsn DBI:mysql:bayes:localhostbayes_sql_override_username bayesbayes_sql_username bayesbayes_sql_password password 

FuzzyOCRを構成する

OCRはリソースを大量に消費するアクティビティであるため、すでにスキャンした画像が再度スキャンされないようにパフォーマンスを向上させるために、画像ハッシュをmysqlデータベースに保存します。

MySQLデータベースを作成する
  • sqlスクリプトはデータベースとテーブルを作成し、パスワードfuzzyocrを使用してユーザーfuzzyocrを追加します。

mysql -p

  • パスワードを変更します:

mysqladmin -u fuzzyocr-pfuzzyocrパスワード

基本設定
  • /etc/mail/spamassassin/FuzzyOCR.cfを編集して、基本的なオプションを設定します。
 focr_path_bin / usr / bin:/ usr / local / binfocr_minimal_scanset 1focr_autosort_scanset 1focr_enable_image_hashing 3focr_logfile /tmp/FuzzyOcr.log 

FuzzyOCRにデータベースを使用させる

  • ファイル/etc/mail/spamassassin/FuzzyOcr.cfを編集して、次を追加します。
 focr_mysql_db FuzzyOcrfocr_mysql_hash Hashfocr_mysql_safe Safefocr_mysql_user fuzzyocrfocr_mysql_pass passwordfocr_mysql_host localhostfocr_mysql_port 3306focr_mysql_socket /var/lib/mysql/mysql.sock 

SAREルールの更新

  • ルールの署名に使用されるGPGキーをインポートします:

mkdir / etc / mail / spamassassin / sa-update-keys /
chmod 700 /etc/mail/spamassassin/sa-update-keys/
wget http://daryl.dostech.ca/sa- update / sare / GPG.KEY
sa-update --import GPG.KEY

  • チャネルファイル/etc/mail/spamassassin/sare-sa-update-channels.txtを作成します:
 updates.spamassassin.org72_sare_redirect_post3.0.0.cf.sare.sa-update.dostech.net70_sare_evilnum0.cf.sare.sa-update.dostech.net70_sare_bayes_poison_nxm.cf.sare.sa-update.dostech.net70_sare_ .sa-update.dostech.net70_sare_html_eng.cf.sare.sa-update.dostech.net70_sare_header0.cf.sare.sa-update.dostech.net70_sare_header_eng.cf.sare.sa-update.dostech.net70_sare_specific.cf.sare.sa -update.dostech.net70_sare_adult.cf.sare.sa-update.dostech.net72_sare_bml_post25x.cf.sare.sa-update.dostech.net99_sare_fraud_post25x.cf.sare.sa-update.dostech.net70_sare_spoof.cf.sare.sa .dostech.net70_sare_random.cf.sare.sa-update.dostech.net70_sare_oem.cf.sare.sa-update.dostech.net70_sare_genlsubj0.cf.sare.sa-update.dostech.net70_sare_genlsubj_eng.cf.sare.sa-update.dos .net70_sare_unsub.cf.sare.sa-update.dostech.net70_sare_uri0.cf.sare.sa-update.dostech.net70_sare_obfu0.cf.sare.sa-update.dostech.net70_sare_stocks.cf.sare.sa-update.dostech.net 
  • 更新スクリプト/usr/ local / bin / update-saを作成します:
#!/ bin / bash ## sa-update -D --channelfile /etc/mail/spamassassin/sare-sa-update-channels.txt --gpgkey 856AA88A&> / var / log/sa-updates。ログ
  • 実行可能にしてcronに追加します:

chmod + x / usr / local / bin / update-sa
ln -s / usr / local / bin / update-sa /etc/cron.daily/
ln -s / usr / local / bin / update-sa /etc/cron.hourly/

Spamass-milterセットアップ

Basic Configuration

  • Edit /etc/sysconfig/spamass-milter:
SOCKET=/var/run/spamass.sockEXTRA_FLAGS="-m -r 8"

Patch

We need to patch the init file to fix the permissions of the socket created such that postfix is able to use the socket.

wget http://www.topdog-software.com/files/spamass-milter.patch
patch /etc/rc.d/init.d/spamass-milter

Apache Setup

Disable Modules

We will disable some modules that we are not using thus freeing up memory and also improving security.

  • Edit /etc/httpd/conf/httpd.conf and comment out the modules as below.
#LoadModule ldap_module modules/mod_ldap.so#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so#LoadModule dav_module modules/mod_dav.so#LoadModule status_module modules/mod_status.so#LoadModule dav_fs_module modules/mod_dav_fs.so#LoadModule proxy_module modules/mod_proxy.so#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so#LoadModule proxy_http_module modules/mod_proxy_http.so#LoadModule proxy_connect_module modules/mod_proxy_connect.so#LoadModule cache_module modules/mod_cache.so#LoadModule disk_cache_module modules/mod_disk_cache.so#LoadModule file_cache_module modules/mod_file_cache.so#LoadModule mem_cache_module modules/mod_mem_cache.so
  • Edit /etc/httpd/conf.d/proxy_ajp.conf and comment out as below:
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

Listen To One IP For HTTPS

Apache has to be configured to listed to one address for port 443 as webmin will be using the same port. Edit /etc/httpd/conf.d/ssl:

Listen 192,168.1.6:443

Enable Gzip Compression

We setup gzip compression via the mod_deflate module to improve web server performance and to cut down on bandwidth usage by compressing responses to the client.

SetOutputFilter DEFLATEBrowserMatch ^Mozilla/4 gzip-only-text/htmlBrowserMatch ^Mozilla/4\.0[678] no-gzipBrowserMatch \bMSIE !no-gzip !gzip-only-text/htmlSetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png)$ no-gzip dont-varyHeader append Vary User-Agent env=!dont-vary

Set up logging for the deflate module:

DeflateFilterNote deflate_ratioLogFormat "%v %h %l %u %t \"%r\" %>s %b mod_deflate:%{deflate_ratio}n pct." vhost_with_deflate_infoCustomLog logs/deflate_access_log vhost_with_deflate_info

Increase PHP Max Memory

Edit the file /etc/php.ini and set the following:

memory_limit =64M

Enable Virtual Hosting

NameVirtualHost *:80

Create Default Virtual Host

This needs to be the first virtual host, it will be the default on the server the equivalent of the server with out virtual hosting.

 Servername localhost.localdomain Serveradmin [email protected]

Roundcube Webmail Setup

データベースの作成
  • Create the database and add the roundcube user.

mysqladmin -p create roundcube
mysql -p
mysql> GRANT ALL ON roundcube.* TO [email protected] IDENTIFIED BY 'password';

  • Initialize the database:

mysql -u roundcube -p roundcube

Basic Config

  • Configure database DSN in /var/www/roundcube/config/db.inc.php:
$rcmail_config['db_dsnw'] ='mysql://roundcube:[email protected]/roundcube';
  • Configure roundcube in /var/www/roundcube/config/main.inc.php:
$rcmail_config['default_host'] ='localhost';$rcmail_config['default_port'] =143;$rcmail_config['virtuser_file'] ='/etc/postfix/virtual';$rcmail_config['smtp_server'] ='localhost';$rcmail_config['smtp_port'] =25;$rcmail_config['smtp_helo_host'] ='localhost';

Set Up Catch All Virtualhost

As we will be providing webmail for all domains that are created on the system we need to setup a catch all virtualhost that can display roundcube when ever a user accesses http://webmail.domainname. Edit /etc/httpd/conf/httpd.conf and append:

ServerName webmail.example.comServerAlias webmail.*DocumentRoot /var/www/roundcubeOptions -Indexes IncludesNOEXEC FollowSymLinksallow from all

Firewall Setup

Introduction

This is a basic firewall it may not suit your needs, firewalling is an art so i recommend to read into it to improve on this basic one.

Basic Config

Add these rules in your configuration file /etc/sysconfig/iptables:

*raw:PREROUTING ACCEPT [0:0]:OUTPUT ACCEPT [0:0]COMMIT*nat:PREROUTING ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]:OUTPUT ACCEPT [0:0]COMMIT*mangle:PREROUTING ACCEPT [0:0]:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]COMMIT*filter:FORWARD DROP [0:0]:INPUT DROP [0:0]:OUTPUT DROP [0:0]-A INPUT -i lo -j ACCEPT-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT-A INPUT -p tcp -m multiport -j ACCEPT --dports 80,443,25,110,143,53-A INPUT -p udp -m udp --dport 53 -j ACCEPT-A INPUT -p icmp -m icmp -m limit --icmp-type 8 --limit 5/min -j ACCEPT-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A OUTPUT -s 127.0.0.1 -j ACCEPT-A OUTPUT -s 192.168.1.5 -j ACCEPT-A OUTPUT -s 192.168.1.6 -j ACCEPTCOMMIT

Activate Config

service iptables restart

Virtual Hosting Howto With Virtualmin On CentOS 5.1 - Page 6

Configure Virtualmin

Introduction

Virtualmin is a powerful and flexible hosting control panel that integrates with webmin. We will be using it to provide the virtual hosting functions such as creation of domains, accounts and maintaining configurations on the system.

Start Services

You need to start up services that are required to be able to configure virtualmin. Start the following services:

service named start
service spamassassin start
service spamass-milter start
service clamav-milter start
service postfix start
service dovecot start
service imapproxy start
service httpd start

Initial Settings

MySQL

Webmin needs to be able to communicate with mysql since we have set a password for mysql we need to set that up in webmin, go to servers ? mysql and enter this information:

Configure Features

You need to enable the features and plugins that we want to use. On login this is the screen that you will see.

  • Enable the following features and save
    • Home directory
    • Administration user
    • Mail for domain
    • BIND DNS domain
    • Apache website
    • Webalizer reporting
    • Log file rotation
    • Mysql database
    • Webmin user

Configure Server Templates

Server template are used to customize the services and to create packages for different hosting account types.

Apache Template

You can make changes to the way apache virtual hosts are created by editing this template, The defaults however will do for purposes of this howto.

Domain Owner Template

This template is used to configure various server limits such as number of mailboxes,aliases,databases,virtual servers and other options like bandwidth limits, admin abilities. For this howto we will use the default values.

Home Directory Template

This template allows you to set a skel directory to hold setting for new users for this howto we will use the defaults.

Administration User

This template lets you set the quota for the virtual server and the admin user for this howto we will use the default quota 1GB.

Mail For Domain Template

This template sets various mail related options, we will modify the email message sent on server creation to have the content below:

The following virtual server has been set up successfully :Domain name:${DOM}Hosting server:${HOSTNAME}${IF-VIRT}Virtual IP address:${IP}${ENDIF-VIRT}Administration login:${USER}Administration password:${PASS}${IF-WEBMIN}Administration URL:${WEBMIN_PROTO}://www.${DOM}:${WEBMIN_PORT}/${ENDIF-WEBMIN}${IF-WEB}Website:http://www.${DOM}/${IF-WEBALIZER}Webalizer log reporting:Enabled${ELSE-WEBALIZER}Webalizer log reporting:Disabled${ENDIF-WEBALIZER}${ENDIF-WEB}${IF-MAIL}Email domain:${DOM}SMTP server:mail.${DOM}POP3 server:mail.${DOM}Webmail:webmail.${DOM}${ENDIF-MAIL}${IF-DNS}DNS domain:${DOM}Nameserver:${HOSTNAME}${ENDIF-DNS}${IF-MYSQL}MySQL database:${DB}MySQL login:${MYSQL_USER}MySQL password:${PASS}${ENDIF-MYSQL}${IF-POSTGRES}PostgreSQL database:${DB}PostgreSQL login:${USER}PostgreSQL password:${PASS}${ENDIF-POSTGRES}

We will leave the other options as the defaults.

BIND DNS Domain Template

This template is used to customize the zones that will be created by virtualmin. The changes to be made are adding a spf record, add the following records to auto generated text box (replace ns1.home.topdog-software.com. with your slave server):

@ IN NS ns1.home.topdog-software.com.;slaveadmin IN A 192.168.1.6;virtualminwebmail IN A 192.168.1.5;webmail

In the directives text box add the following with the IP address of your slave server such that the slave is allowed to do zone transfers.

allow-transfer { 192.168.1.2; };

MySQL Database Template

Contains options on creation of databases by virtualmin, for the howto we will use the defaults.

Webmin Login Template

Contains option on creation of new users by virtualmin, for the howto we will use the defaults.

Create Virtual Server

Finally we have a working virtual server system, lets create our first virtual server. Go to servers ? virtualmin virtual servers and click add new virtual server, owned by new user.

Fill in the require fields and click create.

Add a mail user to the domain. click on the domain name, then click edit mail and FTP users, then add user and fill in the information.

Testing

Postfix

Test SMTP

telnet 192.168.1.5 25
Connected to localhost.
Escape character is '^]'.
220 tds mail cluster
helo me
250 hosting1
mail from:[email protected]
250 2.1.0 Ok
rcpt:[email protected]
250 2.1.0 Ok
DATA
354 End data with .

From:[email protected]
To:[email protected]
Subject:This is a test
Hi
This is a test
.
250 2.0.0 Ok:queued as 4ACCC7C5A6

telnet 192.168.1.5 25
Trying 192.168.1.5...
Connected to localhost.
Escape character is '^]'.
220 tds mail cluster
ehlo me
250-hosting1
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Test dkim

Send a mail to [email protected]

Test domainkeys

Send a mail to [email protected]

Dovecot

Test POP3

telnet 192.168.1.5 110
+OK Dovecot ready.
user andrew.example
+OK
pass password
+OK Logged in.
quit
+OK Logging out.

Test IMAP

telnet 192.168.1.5 143
* OK Dovecot ready.
01 login andrew.example password
01 OK User logged in
01 list "" "*"

* LIST (\HasNoChildren) "." "Trash"
* LIST (\HasNoChildren) "." "Drafts"
* LIST (\HasNoChildren) "." "Junk"
* LIST (\HasNoChildren) "." "Sent"

* LIST (\HasNoChildren) "." "INBOX"
01 OK List completed.
01 logout
* BYE LOGOUT received
01 OK Completed

BIND

dig example.com @127.0.0.1

Clamav-milter

We are using the test virus from www.eicar.org.

telnet 192.168.1.5 25
Connected to localhost.
Escape character is '^]'.
220 tds mail cluster
helo me
250 hosting1
mail from:[email protected]
250 2.1.0 Ok
rcpt:[email protected]
250 2.1.0 Ok
DATA
354 End data with .

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
.
550 5.7.1 virus Eicar-Test-Signature detected by ClamAV - http://www.clamav.net
quit
221 2.0.0 Bye

Take a lot at your /var/log/maillog you should see something like this:

73BC87C4E4:milter-reject:END-OF-MESSAGE from localhost[127.0.0.1]:5.7.1 virus Eicar-Test-Signature detected by ClamAV - http://www.clamav.net; from= to= proto=SMTP helo=

Spamass-milter

We are using the test message from http://spamassassin.apache.org/gtube/.

telnet 192.168.1.5 25
Connected to localhost.
Escape character is '^]'.
220 tds mail cluster
helo me
250 hosting1
mail from:[email protected]
250 2.1.0 Ok
rcpt:[email protected]
250 2.1.0 Ok
DATA
354 End data with .

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
.
550 5.7.1 Blocked by SpamAssassin
quit
221 2.0.0 Bye

You will see this in your log files:

spamd:result:Y 1002 - AWL,GTUBE,MISSING_SUBJECT,TVD_SPACE_RATIO,UNPARSEABLE_RELAY scantime=0.5,size=723,user=root,uid=99,required_score=5.0,

Panels
  1. VSFTPDを使用してCentOS7にFTPサーバーをインストールする方法

  2. ISPConfigを使用するサーバーにいくつかのプラグインを使用してAWStatsをインストールする方法

  3. CentOS6を使用して仮想サーバーにSpamAssassinをインストールする方法

  1. CentOS7でVSFTPDを使用してFTPサーバーをセットアップする方法

  2. CentOS8でVSFTPDを使用してFTPサーバーをセットアップする方法

  3. CentOS 7.0でのPureFTPdとMySQL(クォータと帯域幅の管理を含む)を使用した仮想ホスティング

  1. WebminでCentOS7サーバーを管理する方法

  2. Ubuntu12.04でのvsftpdとMySQLを使用した仮想ホスティング

  3. Ubuntu12.10でのvsftpdとMySQLを使用した仮想ホスティング