Osmany wrote:
Hi everyone,
I have two relay servers currently working with load balancing. I want
to configure both servers so that each MX relays only certain domain and
the rest of the mail throws it to the other MX. Here is the idea:
I want one MX to get all the mail and throw to the other MX all the mail
that has a domain.ca destination so that the other MX takes care of it.
I want the second MX to get all the mail and throw all the mail that
does not have a domain.ca destination so that the other MX takes care of
it.
I have thought about using transports but I don't know how to make an
exception in the transport tables.
I put my transports into a mysql table (so that I can edit them with a
small web based application)
The transport table looks something like:
transports {
lookup varchar,
transport varchar,
host varchar,
active bool
}
Then slightly customise the cf files on each server to only check
transports where host=="1.2.3.4" or host="*". Actually I get the mysql
server to try and figure out the IP address, but be prepared for some
subtleties in making this work (if you don't understand it then don't
use it!)
query = SELECT transport
FROM transports
WHERE lookup = '%s'
and flag_active = '1'
and (host = SUBSTRING_INDEX(CURRENT_USER, '@', -1) OR host = '*')
Variations on this theme allow you to have per machine transports. In
this way I can do some forceable redirection
Additionally my "users" table has a server entry in it. In this way I
can push users to different servers and the system knows to route mail
internally to the correct server. I do this by adding another transport
lookup before the transport above:
query = SELECT mail_host
FROM users
WHERE email = '%s'
and flag_active = '1'
and mail_host <> SUBSTRING_INDEX(CURRENT_USER, '@', -1)
result_format = internal_relay:[%s]:1234
...where here I use a custom transport (on port 1234) to do the internal
relaying so that I can skip some steps when I re-inject on the final
server (performance tweak only, eg don't spam scan again)
In this way any of the backend servers can also serve as a frontend
server, accept mail and route it to the final destination. Similar
tweaks can be done with Dovecot proxying to have the pop/imap servers
act as a mixed frontend/backend setup.
Good luck
Ed W