GNU/Linux >> Linux の 問題 >  >> Ubuntu

LDAPバックエンドとUbuntuBionicBeaver18.04LTSのIMAP/POP3サーバーとしてのDovecotを使用したPostfix仮想ホスティング

このハウツーでは、LDAPバックエンドを使用して仮想メールホスティングを設定および構成する方法について説明します。

このハウツーで使用するソフトウェア:Postfix(MTA)、Dovecot(IMAP / POP3)、Gnarwl(休暇)、OpenLDAP(LDAP)、vMailpanelを管理インターフェースとして使用します。

オプションとして、Proftpd FTP、Roundcube(ウェブメール)、MariaDB(RoundcubeのSQLバックエンド)があります。

これは私にとってはうまくいきましたが、この設定があなたのために働くことを保証することはできませんので、このハウツーは保証なしで来ます。

前提条件

このハウツーでは、次の構成を想定しています。インストールがこれと異なる場合は、以下のエントリを実際の構成に置き換えてください。

メール配信(メールボックス)パス:

/home/vmail/

ユーザーvmail:

UID:1000, GID:1000

ユーザーの接尾辞:

UID: 108, GID:108

OpenLDAPベースDN:

dc=example,dc=tld

OpenLDAP管理者アカウント:

cn=admin,dc=example,dc=tld

vMailpanel検索dn:

o=hosting,dc=example,dc=tld

o =hosting、dc =example、dc =tldツリーの読み取り専用アカウント:

cn=vmail,o=hosting,dc=example,dc=tld

このガイドでは、ユーザーとしてrootを使用しています。

たとえば、o=maildomainsやou=domainsが必要な場合は、特にacl.ldifで、o=hostingを必要なものに置き換えてください。このaclファイルは厳密であり、正しくない場合、phammは正しく機能しません。 phammとは異なる読み取り専用ユーザーが必要な場合は、cn=phammをcn=watに置き換えてください。この方法はどこにでもあります。

このガイドでは、Ubuntuサーバーを必要に応じてインストールおよび構成していることも前提としています。たとえば、Howtoforgeに関する優れたガイドがたくさんあります。

完璧なサーバー-Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot、ISPConfig3.1を搭載したUbuntu18.04(Bionic Beaver)

Apache2のインストールと構成後に停止できます。

ステップ1:vMailpanelをダウンロードする

vMailpanelパッケージをダウンロードします:

cd /usr/share

最新バージョンのvMailpanelを入手する:

git clone https://git.com/wolmfan68/vMailpanel

OK、これで開始できます。

ステップ2:OpenLDAPをインストールして設定する

OpenLDAPとldap-utilsをインストールします:

apt -y install slapd ldap-utils php-ldap

slapdを再構成して、必要な設定が反映されていることを確認します

dpkg-reconfigure slapd

いくつかの質問に答える必要があります:

Omit OpenLDAP server configuration? No
 DNS domain name: example.tld ==>put your domain name here
Organization name: example.tld ==> put your organization here
 Administrator password: secret ==> put your password
 Confirm password: secret 
Database backend to use: MDB
 Do you want the database to be removed when slapd is purged? Yes
 Move old database? Yes

/ etc / ldap / schemaディレクトリに移動します:

cd /etc/ldap/schema

phamm.schemaとperversia.net.schemaをphammパッケージからスキーマディレクトリにコピーします。

cp /usr/share/vMailbox/schema/* /etc/ldap/schema.

次に、スキーマをopenldapに追加します。

ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/phamm.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/ISPEnv2.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/amavis.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/pureftpd.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/perversia.net.ldif

次に、o=hostingエントリとvmailアカウントを作成します。

以下のテキストをニーズと要望に合わせて変更し、vmailアカウントのパスワードを生成します。現在このファイルにあるハッシュは、パスワードを読み取り専用に設定します

vmailアカウントのハッシュを作成するには、次のコマンドを発行します。

slappasswd -h {MD5}

必要なパスワードを2回入力し、その結果を下のテキストにコピーします。

nano base.ldif

base.ldifの内容

dn: o=hosting,dc=example,dc=tld
objectClass: organization
objectClass: top
o: hosting description: Hosting Organization
# Read only account
dn: cn=vmail,o=hosting,dc=example,dc=tld
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: vmail
userPassword: {MD5}M267sheb6qc0Ck8WIPOvQA==
description: Read only account

次のコマンドを使用して、ベースdnをデータベースにロードします。

ldapmodify -a -D cn=admin,dc=example,dc=tld -W -f base.ldif

次に、各ユーザータイプに正しいアクセス権が付与されるように、ACLを変更する必要があります。

ldapmodify -Y EXTERNAL -H ldapi:/// -f acl-remove.ldif
ldapmodify -Y EXTERNAL -H ldapi:/// -f acl-new.ldif

次のコマンドを使用して、新しいACLを確認できます。

slapcat -n 0

これでOpenLDAP構成は完了です。

ステップ3:Postfixをインストールして設定する

その前に、vmailユーザーとそのホームディレクトリが必要です。

vmailのユーザーとグループを作成します:

useradd vmail

デフォルトでは、グループvmailも作成されます。

/ etc / passwdで、実際のuidとグループ番号を確認してください。

次に、vmailディレクトリを作成し、所有権をvmailユーザーとグループに設定します。

mkdir /home/vmail
mkdir /home/vmail/domains 
chown -R vmail:vmail /home/vmail

次のコマンドを実行して、Postfixおよびその他の必要なアプリケーションをインストールします。

apt install postfix postfix-ldap

2つの質問があります。次のように答えてください:

メール構成の一般的なタイプ:<-スタンドアロン
システムメール名:<-mail.example.tld

Dovecot LDAを使用して配信するため、saslはインストールしません。

次に、TLSの証明書を作成します:

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

注:examples/postfixの下にあるすべてのファイルをetc/postfixディレクトリにコピーし、それに応じて変更を加えることができます。完全を期すために、以下に完全なセットアップを示します。

次に、postfixを設定します:

cd /etc/postfix 
mv /etc/postfix/main.cf /etc/postfix/main.cf.bck
nano /etc/postfix/main.cf

そして、それに以下を貼り付けます。この構成では、認証されたユーザーによるメールの送信(リレー)と、構成されている場合はそれぞれのエイリアスへのローカルメール(たとえば、root、postmasterなど)の送信が可能になることに注意してください。

smtpd_banner =$ myhostname ESMTP $ mail_name
biff =no

#.domainの追加はMUAの仕事です。
append_dot_mydomain =no

#次のコメントを解除します「遅延メール」警告を生成する行
delay_warning_time=4h

#TLSパラメータ
smtpd_tls_cert_file =/etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file =/ etc /postfix/ssl/smtpd.key
smtpd_use_tls =yes
smtpd_tls_session_cache_database =btree:$ {queue_directory} / smtpd_scache
smtp_tls_session_cache_database =btree:$ {queue_directory} / smtp_scache
> myhostname =mail.example.tld
alias_maps =hash:/ etc / aliases、
alias_database =hash:/ etc / aliases
myorigin =localhost
relayhost =
mynetworks =127.0.0.0/8
dovecot_destination_recipient_limit =1
mailbox_command =/ usr / lib / delivery
mailbox_size_limit =0
receive_delimiter =+
inet_interfaces =all
inet_protocols =all
#smtp_bind_address =あなたのIPアドレス(オプション)==>セットアップのIPアドレスのマークを外して変更します。
smtpd_sasl_local_domain=
smtpd_sasl_auth_enable =yes
smtpd_sasl_security_options =noanonymous
smtpd_sasl_type =dovecot
smtpd_sasl_path> broken_sasl_auth_clients =yes
smtpd_tls_auth_only =no

smtp_use_tls =yes
smtp_tls_note_starttls_offer =yes
smtpd_tls_CAfile =/ etc / postfix / ssl / cacert =1
smtpd_tls_received_header =yes
smtpd_tls_session_cache_timeout =3600s
tls_random_source =dev:/ dev / urandom

home_mailbox =Maildir /

smtpd_recipient_restrictions =

permit_mynetworksでpermit_sasl_authenticated

reject_invalid_hostname reject_non_fqdn_hostname

reject_non_fqdn_sender reject_non_fqdn_recipient

reject_unauth_destinationのreject_unauth_pipelining

reject_invalid_hostname reject_unknown_sender_domain
拒否_ rbl_client list.dsbl.org
subject_rbl_client cbl.abuseat.org
require_rhsbl_sender dsn.fc-ignorant.org

smtpd_data_restrictions =
subject_unauth_pipelining、

許可

smtpd_helo_required =yes

#transport_maps
maildrop_destination_concurrency_limit =2
maildrop_destination_recipient_limit =1
gnarwl_destination_concurrency_limit =1> gnarwl_destination_recipient_limit =1
transport_maps =hash:/ etc / postfix /transport、ldap:/etc/postfix/ldap-transport.cf
mydestination =$transport_maps、localhost、localhost.localdomain、$ myhostname、localhost 。$mydomain、$ mydomain

virtual_alias_maps =
ldap:/etc/postfix/ldap-aliases.cf、
ldap:/etc/postfix/ldap-virtualforward.cf、
ldap:/etc/postfix/ldap-accountsmap.cf

配信用の#仮想アカウント
virtual_mailbox_base =/ home / vmail
virtual_mailbox_maps =
ldap :/etc/postfix/ldap-accounts.cf
virtual_minimum_uid =1000==>これをユーザーvmailの実際のuidに変更します
virtual_uid_maps=static:1000==>これをの実際のuidに変更しますユーザーvmail
virtual_gid_maps =static:1000==>これをユーザーvmailの実際のuidに変更します

local_recipient_maps =$ alias_maps

receiveie_bcc_maps =ldap:/ etc / postfix / ldap-vacation.cf

nano /etc/postfix/master.cf

そして、それに以下を貼り付けます(末尾を追加します):

dovecot   unix  -       n       n       -       -       pipe
         flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
gnarwl    unix  -       n       n       -       -       pipe
         flags=F  user=vmail argv=/usr/bin/gnarwl -a ${user}@${nexthop} -s ${sender}

次に、別のldap-xxx.cfファイルを作成する必要があります

nano ldap-accounts.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readmonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(objectClass =VirtualMailAccount)(mail =%s))(forwardActive =FALSE)(accountActive =TRUE)(delete =FALSE))
result_attribute=メールボックス

nano ldap-accounstmap.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(objectClass =VirtualMailAccount)(mail =%s))(forwardActive =FALSE)(accountActive =TRUE)(delete =FALSE))
result_attribute =mail

nano ldap-aliases.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(objectClass =VirtualMailAlias)(mail =%s))(accountActive =TRUE))
result_attribute =maildrop

nano ldap-transport.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(vd =%s)( objectClass =VirtualDomain))(accountActive =TRUE)(delete =FALSE))
result_attribute =postfixTransport

nano ldap-vacation.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(objectClass =VirtualMailAccount)(mail =%s))(vacationActive =TRUE)(forwardActive =FALSE)(accountActive =TRUE)(delete =FALSE))
result_attribute =mailAutoreply

nano ldap-virtualforward.cf

そして、それに以下を貼り付けます:

server_host =localhost
server_port =389
version =3
bind =yes
start_tls =no
bind_dn =cn =vmail、o =hosting、dc =example、dc =tld
bind_pw =readonly
search_base =o =hosting、dc =example、dc =tld
scope =sub
query_filter =(&(&(objectClass =VirtualMailAccount)(mail =%s))(vacationActive =FALSE)(forwardActive =TRUE)(accountActive =TRUE)(delete =FALSE))
result_attribute =maildrop

これでpostfixの設定は完了です。

ステップ4:Dovecotをインストールして構成する

apt install dovecot-imapd dovecot-pop3d dovecot-ldap

これにより、dovecotと必要なすべてのファイルがインストールされ、IMAPとPOP3の標準SSL証明書も作成されます。

まず、dovecotディレクトリに移動します。

注:examples/dovecotの下にあるすべてのファイルをetc/dovecotディレクトリにコピーし、それに応じて変更を加えることができます。完全を期すために、以下に完全なセットアップを示します。

 cd /etc/dovecot

次に、さまざまなdovecot構成ファイルを構成します。

nano dovecot-ldap.conf.ext

そして、次の変更を加えます。

ホスト=localhost:389
ldap_version =3
auth_bind =yes
dn =cn =vmail、o =hosting、dc =example、dc =tld
dnpass
dnpass /> base =o =hosting、dc =hosting、dc =tld
scope =subtree
deref =never

user_attrs =quota =quote =maildir:storage
user_attrs =quota =quote =maildir:storage =%$ B
user_filter =(&(objectClass =VirtualMailAccount)(accountActive =TRUE)(mail =%u))
pass_attrs =mail、userPassword
pass_filter =(&(objectClass =VirtualMailAccount)(accountActive =TRUE)(mail =%u))
default_pass_scheme =MD5

cd conf.d
vi 10-auth.conf

そして、[パスワードとユーザーデータベース]セクションを次のように変更します。

#!include auth-deny.conf.ext
#!include auth-master.conf.ext

#!include auth-system.conf.ext
#!include auth -sql.conf.ext
!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

vi 10-mail.conf 

そして、次の変更を加えます。

mail_location =maildir:/ home / vmail /%d /%u

mail_uid =1000==>実際のvmailuid値に変更

mail_gid =1000==>これを実際のvmailgid値に変更します

first_valid_uid =1000==>実際のvmailuid値に変更

first_valid_gid =1000==>これを実際のvmailgid値に変更します

vi 10-master.conf 

そして、次の変更を加えます。

unix_listener auth-userdb {
mode =0666
user =vmail
group =vmail
}

#Postfix smtp-auth
unix_listener / var / spool / postfix / private / auth{
モード=0666
}

 vi 15-lda.conf

そして、次の変更を加えます。

postmaster_address=[メール保護]

lda_mailbox_autocreate =yes

これでDovecotの構成は完了です。

ステップ5:gnarwlをインストールして構成する

gnarwlをインストールしましょう:

apt install gnarwl

それでは、gnarwlを構成しましょう。

まず、元の構成ファイルをバックアップして、新しい構成ファイルに置き換えます。

mv /etc/gnarwl.conf /etc/gnarwl.conf.bck

次に、新しいconfファイルを作成します。

vi /etc/gnarwl.conf

そして、以下を挿入します:

map_sender $sender
map_receiver $recepient
map_subject $subject
map_field $begin vacationStart
map_field $end vacationEnd
map_field $fullname cn
map_field $deputy vacationForward
map_field $reply mail
server localhost
port 389
scope sub
login cn=vmail,o=hosting,dc=example,dc=tld
password readonly
protocol 0
base dc=example,dc=tld
queryfilter (&(mailAutoreply=$recepient)(vacationActive=TRUE))
result vacationInfo
blockfiles /var/lib/gnarwl/block/
umask 0644
blockexpire 48
mta /usr/sbin/sendmail -F $recepient -t $sender
maxreceivers 64
maxheader 512
charset ISO8859-1
badheaders /var/lib/gnarwl/badheaders.db
blacklist /var/lib/gnarwl/blacklist.db
forceheader /var/lib/gnarwl/header.txt
forcefooter /var/lib/gnarwl/footer.txt
recvheader To Cc
loglevel 3

vmailユーザーがgnarwlディレクトリを読み取り可能にする

chown -R vmail:vmail /var/lib/gnarwl/

次に、接尾辞に節点トランスポートを追加する必要があります

vi /etc/postfix/transport

以下を挿入します:

.autoreply      gnarwl:

次に、transport.dbを作成する必要があります

postmap /etc/postfix/transport

これで、節の構成は完了です。

ステップ6:vMailpanelのインストールと構成

以前にvMailpanelをダウンロードしたので、vMailpanelインターフェースの構成から直接始めることができます。

chown -R www-data:www-data /usr/share/phamm
cd /usr/share/vMailpanel

次に、実際に使用するためにphammを構成します。

cp config.inc.example.php config.inc.php
nano config.inc.php

実際の構成に合わせてLDAP接続パラメーターを変更してください。

// *============================*
// *=== LDAP Server Settings ===*
// *============================*

// The server address (IP or FQDN)
define ('LDAP_HOST_NAME','127.0.0.1');

// The protocol version [2,3]
define ('LDAP_PROTOCOL_VERSION','3');

// The server port
define ('LDAP_PORT','389');

// The container
define ('SUFFIX','dc=example,dc=tld');

// The admin bind dn (could be rootdn)
define ('BINDDN','cn=admin,dc=example,dc=tld');

// The Phamm container
define ('LDAP_BASE','o=hosting,dc=example,dc=tld');

と変更

// Welcome message
define ('SEND_WELCOME',1);
$welcome_msg = '../welcome_message.txt';
$welcome_subject = 'Welcome!';
# $welcome_sender = '[email protected]';
$welcome_bcc = '[email protected]';

これにより、ウェルカムメッセージとBCCがポストマスターアカウントに送信されます。

プラグインセクションの//を削除して、fptおよびpersonプラグインを有効にします。必要に応じて、davicalプラグインやjabberプラグインを有効にすることもできます。これらのプラグインに必要なスキーマがインストールされます。

config.inc.phpには、次のものがあります。

define ('DELETE_ACCOUNT_IMMEDIATELY', false);

これをtrueに設定すると、アカウントまたはドメインの削除がすぐに有効になります。ただし、物理メールボックス(またはドメインディレクトリ)は削除されません。物理メールボックスを削除するには、cleaner.shスクリプトを使用する必要があります。これについては以下で説明します。

plugins / mail.xmlを編集して、SMTPとクォータのデフォルトを変更し、必要に応じて変更できます。デフォルトは1GBのクォータに設定されています。

plugins / ftp.xmlを編集して、デフォルトのftp(ベース)ディレクトリとクォータのデフォルトを変更し、必要に応じて変更できます。

ポストマスター、ウェブマスターのエイリアスやメールボックスを作成することを忘れないでください。これらは、次の場合にメールを送信するために公式およびISPによって使用されます...これらのアドレスがないと、ブラックリストに登録される可能性があります。

デフォルトでは、[メール保護]と[メール保護]のエイリアスが作成されます。デフォルトでは[メール保護]になっています。

さて、よりクリーンなスクリプト:

cp tools/cleaner.sh /home/vmail/cleaner.sh

cleaner.shで以下を変更します

BINDDN="cn=admin,dc=example,dc=tld"
BINDPW="password"
LDAP_BASE="o=hosting,dc=example,dc=tld"

インストールを反映するには

nano /home/vmail/cleaner.sh
crontab -e

以下を挿入します:

*/10 * * * * /home/vmail/cleaner.sh

これにより、10分ごとにクリーンなスクリプトが実行されます。タイミングはお気軽に変更してください。

次に、vMailpanelをApacheに追加します

nano /etc/apache2/conf-enabled/000-default.conf

そして、エントリの間に次を追加します。

Alias /vmailpanel /usr/share/vMailpanel/public

これでvMailpanelの構成は完了です。

ステップ7:RoundcubeWebメールをインストールして構成する

まず、roundcubeというデータベースを作成します:

mysqladmin -u root -p create roundcube

次に、MySQLシェルに移動します:

mysql -u root -p

MySQLシェルでは、roundcubeデータベースにSELECT、INSERT、UPDATE、DELETE権限を持つユーザーroundcubeをパスワードroundcube_password(選択したパスワードに置き換えます)で作成します。このユーザーは、PostfixとCourierがroundcubeデータベースに接続するために使用されます:

GRANT SELECT, INSERT, UPDATE, DELETE ON roundcube.* TO 'roundcube'@'localhost' IDENTIFIED BY 'roundcube_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON roundcube.* TO 'roundcube'@'localhost.localdomain' IDENTIFIED BY 'roundcube_password';
FLUSH PRIVILEGES;

次に、Roundcubeをダウンロードしてインストールします:

cd/usr/src 
wget https://github.com/roundcube/roundcubemail/releases/download/1.3.6/roundcubemail-1.3.6.tar.gz
tar xvzf roundcubemail-1.3.6.tar.gz
mv roundcubemail-1.3.6 /var/www/roundcube
chown -R www-data:www-data /var/www/roundcube
cd /var/www/roundcube

常に最新バージョンのRoundcubeを確認し、それをダウンロードして、上記のコマンドをダウンロードしたRoundcubeのバージョンに変更してください。

https://roundcube.net/download/

次に、前に作成したデータベースにSQLテーブルをロードします。

mysql -u roundcube -p roundcube <  SQL/mysql.initial.sql

次に、Roundcube構成を編集します:

cp config/config.inc.php.sample config/config.inc.php

データベース構成を設定します:

nano config/config.inc.php

次の行をデータベース構成に変更します。

$rcmail_config['db_dsnw'] = 'mysql://roundcube:[email protected]/roundcube';

そして、以下を変更します

差出人:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array(
    'archive', 
    'zipdownload',

宛先:

// List of active plugins (in plugins/ directory)
$config['plugins'] = array(
    'archive', 
    'zipdownload',
    'password',
    'vacation', 

変更:

chars.$rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str';

宛先:

chars.$rcmail_config['des_key'] = 'your-own-24-digitkeystring';

変更:

$rcmail_config['default_host'] = '';

宛先:

$rcmail_config['default_host'] = 'localhost'; 

変更:

$rcmail_config['smtp_server'] = ''; 

宛先

$rcmail_config['smtp_server'] = 'localhost'; 

パスワードプラグインの構成:

cp plugins/password/config.inc.php.dist plugins/password/config.inc.php

構成を編集します:

nano plugins/password/config.inc.php

次のエントリを変更します

差出人:

$rcmail_config['password_driver'] = 'sql';

宛先:

$rcmail_config['password_driver'] = 'ldap'; 

差出人:

// LDAP Driver options
// -------------------
// LDAP server name to connect to.
// You can provide one or several hosts in an array in which case the hosts are tried from left to right.
// Exemple: array('ldap1.exemple.com', 'ldap2.exemple.com');
// Default: 'localhost'
$rcmail_config['password_ldap_host'] = 'localhost';

// LDAP server port to connect to
// Default: '389'
$rcmail_config['password_ldap_port'] = '389';

// TLS is started after connecting
// Using TLS for password modification is recommanded.
// Default: false
$rcmail_config['password_ldap_starttls'] = false;

// LDAP version
// Default: '3'
$rcmail_config['password_ldap_version'] = '3';

// LDAP base name (root directory)
// Exemple: 'dc=exemple,dc=com'
$rcmail_config['password_ldap_basedn'] = 'dc=exemple,dc=com';

// LDAP connection method
// There is two connection method for changing a user's LDAP password.
// 'user': use user credential (recommanded, require password_confirm_current=true)
// 'admin': use admin credential (this mode require password_ldap_adminDN and password_ldap_adminPW)
// Default: 'user'
$rcmail_config['password_ldap_method'] = 'user';

// LDAP Admin DN
// Used only in admin connection mode
// Default: null
$rcmail_config['password_ldap_adminDN'] = null;

// LDAP Admin Password
// Used only in admin connection mode
// Default: null
$rcmail_config['password_ldap_adminPW'] = null;

// LDAP user DN mask
// The user's DN is mandatory and as we only have his login,
// we need to re-create his DN using a mask
// '%login' will be replaced by the current roundcube user's login
// '%name' will be replaced by the current roundcube user's name part
// '%domain' will be replaced by the current roundcube user's domain part
// Exemple: 'uid=%login,ou=people,dc=exemple,dc=com'
$rcmail_config['password_ldap_userDN_mask'] = 'uid=%login,ou=people,dc=exemple,dc=com';

// LDAP password hash type
// Standard LDAP encryption type which must be one of: crypt,
// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear.
// Please note that most encodage types require external libraries
// to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info.
// Default: 'crypt'
$rcmail_config['password_ldap_encodage'] = 'crypt';

// LDAP password attribute
// Name of the ldap's attribute used for storing user password
// Default: 'userPassword'
$rcmail_config['password_ldap_pwattr'] = 'userPassword';

// LDAP password force replace
// Force LDAP replace in cases where ACL allows only replace not read
// See http://pear.php.net/package/Net_LDAP2/docs/latest/Net_LDAP2/Net_LDAP2_Entry.html#methodreplace
// Default: true
$rcmail_config['password_ldap_force_replace'] = true;

宛先:

$rcmail_config['password_ldap_host'] = 'localhost';
$rcmail_config['password_ldap_port'] = '389';
$rcmail_config['password_ldap_starttls'] = false;
$rcmail_config['password_ldap_version'] = '3';
$rcmail_config['password_ldap_basedn'] = 'o=hosting,dc=example,dc=tld';

$rcmail_config['password_ldap_method'] = 'user';
$rcmail_config['password_ldap_adminDN'] = null;
$rcmail_config['password_ldap_adminPW'] = null;

$rcmail_config['password_ldap_userDN_mask'] = 'mail=%login,vd=%domain,o=hosting,dc=example,dc=tld';

$rcmail_config['password_ldap_encodage'] = 'md5';
$rcmail_config['password_ldap_pwattr'] = 'userPassword';

$rcmail_config['password_ldap_force_replace'] = true;

次に、休暇プラグインをダウンロードしてインストールします。

cd /usr/src
wget https://github.com/bhuisgen/rc-vacation/archive/master.zip
unzip rc-vacation-master.zip
mv rc-vacation /var/www/roundcube/plugins/vacation
cd /var/www/roundcube/plugins/vacation

次に、構成を編集して変更します。

nano plugins/vacation/config.inc.php

変更:

$rcmail_config['vacation_gui_vacationsubject'] = TRUE;

宛先:

$rcmail_config['vacation_gui_vacationsubject'] = FALSE;

変更:

$rcmail_config['vacation_driver'] = 'sql'; 

宛先:

$rcmail_config['vacation_driver'] = 'ldap';

変更:

// Base DN
$rcmail_config['vacation_ldap_base'] = 'dc=ldap,dc=my,dc=domain';

// Bind DN
$rcmail_config['vacation_ldap_binddn'] =
'cn=user,dc=ldap,dc=my,dc=domain';

// Bind password
$rcmail_config['vacation_ldap_bindpw'] = 'pa$$w0rd';

宛先:

// Base DN
$rcmail_config['vacation_ldap_base'] = 'o=hosting,dc=example,dc=tld';

// Bind DN
$rcmail_config['vacation_ldap_binddn'] = 'cn=admin,dc=example,dc=tld';

// Bind password
$rcmail_config['vacation_ldap_bindpw'] = 'yourpassword';

変更:

// Search filter to read data
$rcmail_config['vacation_ldap_search_filter'] = '(objectClass=mailAccount)';

// Search attributes to read data
$rcmail_config['vacation_ldap_search_attrs'] = array ('vacationActive', 'vacationInfo');

// array of DN to use for modify operations required to write data.
$rcmail_config['vacation_ldap_modify_dns'] = array (
'cn=%email_local,ou=Mailboxes,dc=%email_domain,ou=MailServer,dc=ldap,dc=my,dc=domain'
);

宛先:

// Search base to read data
$rcmail_config['vacation_ldap_search_base'] =
'mail=%username,vd=%email_domain,o=hosting,dc=example,dc=tld';

// Search filter to read data
$rcmail_config['vacation_ldap_search_filter'] = '(objectClass=VirtualMailAccount)';

// Search attributes to read data
$rcmail_config['vacation_ldap_search_attrs'] = array ('vacationActive', 'vacationInfo');

// array of DN to use for modify operations required to write data.
$rcmail_config['vacation_ldap_modify_dns'] = array (
'mail=%username,vd=%email_domain,o=hosting,dc=example,dc=tld'
);

Roundcubeにアクセスできるように、Apche2サーバー構成のドキュメントルートを変更する必要があります。

nano /etc/apache2/sites-enabled/000-default.conf

そして変更元:

DocumentRoot /var/www/html

宛先:

DocumentRoot /var/www/

これで、Roundcubeの構成は完了です。

ステップ8:proftpdをインストールして設定します

まず、proftpdとその要件をインストールします:

apt install proftpd proftpd-mod-ldap

負荷に応じて、スタンドアロンとinet.dのどちらかを決定できます。

注:設定ファイルはexamples/proftpdから/etc/ proftpdにコピーできますが、わかりやすくするために、すべての設定手順の概要を説明します。

/etc/proftpd/proftpd.confを編集します:

nano /etc/proftpd/proftpd.conf

そして変更元:

# Use this to jail all users in their homes
# DefaultRoot                   ~

宛先:

# Use this to jail all users in their homes
DefaultRoot      

そして変更元:

#RequireValidShell               off

宛先:

RequireValidShell               off

And change:

# Alternative authentication frameworks
#
# Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf

To:

# Alternative authentication frameworks
#
Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf
             ~

Now edit /etc/proftpd/modules.conf:

nano /etc/proftpd/modules.conf 

And change from:

# Install proftpd-mod-ldap to use this
#LoadModule mod_ldap.c

To:

# Install proftpd-mod-ldap to use this
LoadModule mod_ldap.c

And from:

# Install proftpd-mod-ldap to use this
# LoadModule mod_quotatab_ldap.c

To:

# Install proftpd-mod-ldap to use this
LoadModule mod_quotatab_ldap.c 

No edit /etc/proftpd/ldap.conf and set the following:

<IfModule mod_ldap.c>
#
#LDAPServer ldap://ldap.example.com
#LDAPBindDN "cn=admin,dc=example,dc=com" "admin_password"
#LDAPUsers dc=users,dc=example,dc=com (uid=%u) (uidNumber=%u)
#LDAPUseTLS on
#
#
#LDAPServer ldaps://ldap.example.com
#LDAPBindDN "cn=admin,dc=example,dc=com" "admin_password"
#LDAPUsers dc=users,dc=example,dc=com (uid=%u) (uidNumber=%u)
#
LDAPServer ldap://127.0.0.1/??sub
LDAPBindDN "cn=vmail,o=hosting,dc=example,dc=tld "readonly"
LDAPUsers "o=hosting,dc=example,dc=tld" "(&(uid=%v)(objectclass=posixAccount))"
LDAPDefaultGID 33
LDAPDefaultUID 33
LDAPForceDefaultGID True
LDAPForceDefaultUID True

</IfModule>

The following commands set the default user to www-data which suits me, you can change these values to suit your setup or leave them out to use the login uid / gid.

LDAPDefaultGID                  33
LDAPDefaultUID 33
LDAPForceDefaultGID True
LDAPForceDefaultUID True

33 Is the uid/gid of my testing setup, it can be different on your setup.

This concludes the proftpd installation.

Step 9:Bringing it all together

Issue the following commands to restart all of the services:

service slapd restart 
service postfix restart
service dovecot restart
service proftpd restart
service apache2 restart

Now you can go to phamm and start adding mail domains and users.

Enjoy.

Note:notify me of any errors or problems with this how to so I can improve and amend this how to.

Use this thread in the forum:

https://www.howtoforge.com/community/threads/postfix-virtual-hosting-with-ldap-backend-and-with-dovecot-as-imap-pop3-server-on-ubuntu-bionic-beav.79408/

I am subscribed to this thread so I will get notifications of new posts in this thread.


Ubuntu
  1. Ubuntu 14.04LTSでのProftpdとMySQL(クォータを含む)を使用した仮想ホスティング

  2. Postfix、Courier、MySQL、SquirrelMailを使用した仮想ユーザーとドメイン(Ubuntu 13.10)

  3. 完璧なサーバー-Apache、PHP、MySQL、PureFTPD、BIND、Postfix、Dovecot、ISPConfig3.1を搭載したUbuntu18.04(Bionic Beaver)

  1. Ubuntu 18.04 LTSサーバー(Bionic Beaver)インストールガイドとスクリーンショット

  2. Ubuntu/DebianサーバーにPostfixとDovecotを使用してSpamassassinをインストールする方法

  3. Ubuntu 18.04 で Dovecot を使用して POP3 / IMAP メール サーバーを構成する方法

  1. VBoxHeadless-ヘッドレスUbuntu16.04LTSサーバーでVirtualBox5.1を使用して仮想マシンを実行する

  2. Ubuntu 18.04 LTS(Bionic Beaver)最小サーバーのインストール方法

  3. Ubuntu20.04LTSにPHP-FPMとMySQLを使用してLighttpdをインストールする方法