Saturday, November 3, 2007

Massive mail and web hosting in Debian

I migrated some web and mail services from a custom Linux distro with Apache2 and Cyrus-imapd to Apache2.2 and Dovecot (imapd + pop3d). Because there are lots of Domains, Subdomains and mail aliases, I wanted to unify as much of the configuration as possible to make maintaining the services easier.

Massive name-based virtual hosting with Apache2

The document "Dynamically configured mass virtual hosting" in the Apache HTTP Server documentation describes how to set up dynamic virtual hosting. I needed name-based virtual hosting, so I created a file "/etc/apache2/conf.d/vhosting" with the following contents:

UseCanonicalName Off
VirtualDocumentRoot /srv/www/%-2.0+.%-1/%-3+/

AllowOverride all
Options +Indexes

This will automatically map subdomain.example.com to /srv/www/example.com/subdomain/. You can then even think of more sophisticated usage, such as placing a .htaccess file with a Redirect directive in /srv/www/redirected-domain.tld/.

Migrating Cyrus mails to Dovecot Maildirs

Fazal Majid has written a Python script that can be found in this blog post. You might have to modify a bit, but apart from that, it serves the purpose well. After you have converted the (nonstandard) Cyrus mail dir to the standard Maildir(++) format, the Maildirs can be used with the Dovecot mail server. Of course, you should configure exim4 to deliver new mail into "Maildir" in the users' home directories.

Massive E-Mail virtual hosting with Exim4

Another problem that arose was multiple domains and different users for E-Mail. Thankfully, Aron HÃ¥kanson has had the same problem and written the article Virtual domains with Exim 4, in which he describes how to set up massive E-Mail virtual hosting on Debian with Exim4. This makes maintaining a plaintext list of mail alias mappings for virtual servers and a list of domains for which to handle mails very easy and keeps the list maintainer happy.

No comments: