This setup is deployed to a Funtoo.org hosted container
This document is intended as a personal reference for myself about the setup of
my particular system, and not so much as a HOWTO for others. I owe thanks to
many resources on the internet, but particularly SwifT’s HOWTO for
Gentoo
Getting Started
My USE flags from /etc/portage/make.conf:
Installed versions of some relevant software:
I will use ylayali.net as the authoritative (or “non-virtual”) domain for
the server, to allow mailing system users (and so my personal account can
continue to use procmail). It needs to be added to /etc/hosts on its own line:
# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 kennethd.host.funtoo.org kennethd localhost localhost.localdomain
::1 kennethd.host.funtoo.org kennethd localhost localhost.localdomain
172.97.103.107 ylayali.net mail.ylayali.net www.ylayali.net media.ylayali.net rt.ylayali.net
The prototype domain for testing virtual host features will be highball.org.
Create vmail User
Install Let’s Encrypt! Client
Let’s Encrypt! SSL Certs will be used for Apache, Postfix & Courier.
I had to pin a lot of dev-python packages to specific versions in package.use to get this to work
Postgres Configuration
There are two versions of Postgres on the system, 9.6 and 10. I think the
9.6 one is from when I last began this setup, a few months ago, and 10.4 was
installed when emerging @world in preparation for this attempt. Gentoo &
Funtoo allow for these parallel installations for upgrades and convenience of
maintenance. I plan to use 9.6 for mail setup, and other systems requiring
The Gentoo Wiki mentions an
optional package, acme-tiny, which
promises to bypass some of the “bloat” of the official client. It requires
setting up an overlay, which are
managed via layman.
stability, and 10 for more experimental app development.
Initial configuration will be read from /etc/conf.d/postgresql-$VERSION,
which defines a couple of important directories, PGDATA is where the postgres
config files will be found, and DATA_DIR where logs and database data will be
stored:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 password
# IPv6 local connections:
host all all ::1/128 password
# Allow replication connections from localhost, by a user with the replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
Try it out: psql -U postgres postgres
Postfix Configuration
I have the following package-specific USE flags:
The only changes to master.cf were the uncommenting of the second and
services listed below (smtp/inet and smtpd/pass)
I’ve reduced my main.cf to include only options that vary from the default:
Create the postgres schema
The virtual host database is queried via the following SQL statements:
Create the postfix user:
Alias root@
Edit /etc/mail/aliases to ensure root@ forwards to your email address.
SPF and DKIM
SPF (Sender Policy Framework)
is a protocol intended to prevent email spoofing by publising (via DNS) a list of IPs
authorized to originate email for a domain.
SMTP-time SpamAssassin & ClamAV Configuration
Courier-imap Configuration
Edit both /etc/courier-imap/{imapd.cnf,pop3d.cnf} to look similar to:
And run:
Cyrus-sasl Configuration
Cyrus-sasl accepts login info for Courier-imap, which Courier then uses to
authenticate against postgres
/etc/sasl2/smtpd.conf
mech_list: PLAIN LOGIN
pwcheck_method: saslauthd
/etc/conf.d/saslauthd
SASLAUTHD_OPTS="${SASLAUTH_MECH} -a rimap -r" SASLAUTHD_OPTS="${SASLAUTHD_OPTS} -O localhost"
And run:
Add Courier-imap services to default runlevel
Apache Configuration
Verify the value of APACHE2_OPTS in /etc/conf.d/apache2