[TriLUG] Using Apache 2 with Multiple domains

Joseph Tate jtate at dragonstrider.com
Fri Jul 9 18:09:57 EDT 2004


Aaron S. Joyner wrote:

> This actually isn't much harder.  Both Sendmail and Postfix do it rather 
> easily via Virtual aliases, and both have very good documentation on how 
> to set it up.  In principle, you setup a file something like this:
> user1 at example.com   asjoyner
> user2 at example2.com   user2
> @example2.com user2
> 
> Now the only addresses in those domains are user1 in the first domain, 
> and user2 in the second domain.  But in the second domain, any address 
> is valid, and all mail to "other" addresses (ala spam at example2.com) goes 
> to user2's mailbox.
> 
> Check out the documentation for your mailer, for the specifics.
> 
> Don't forget the DNS setups - each domain needs to have an MX record 
> which points to the mail host for that domain.  To make the mailers 
> active for the domain, check out /etc/mail/local-host-names for 
> Sendmail, or $mydestinations in main.cf for Postfix.  Don't forget to 
> reload each daemon after you change the config file, kill -HUP 
> `sendmailpid` or postfix reload.
> 
> Enjoy!
> Aaron S. Joyner

If you want anything more sophisticated than this, you could handle it 
at the MDA level.  Cyrus IMAP for example has support for true virtual 
hosting.  Just tell postfix to accept mail from the requested domains, 
and then let cyrus handle mail delivery to the proper user.  The nice 
thing about this is the users don't have to have accounts on the box.

Cyrus is a little complex though, and could take some getting used to.



More information about the TriLUG mailing list