Automatically Sync Mailcow Addresses to Failover Instances
909
Source Code: git.tjdev.de/DrMaxNix/moosync
Automatically Sync Mailcow Addresses to Failover Instances
MX 10. The failover server(s) has/have lower priority; eg. MX 20.For the following instructions, we will assume following:
srv0.example.com (IP address: 203.0.113.1)mx0.example.commx1.example.com (and optionally another one at mx2.example.com, etc.)$SHOW_DKIM_PRIV_KEYS = true; to data/web/inc/vars.local.inc.php. Restarting is not required.srv0 to the list of allowed networks (eg. 203.0.113.1). Make sure to save changes.mx1.example.com (and all other failover systems) as forwarding hosts. Keeping the spam filter enabled will work in most setups.srv0 to the list of allowed networks (eg. 203.0.113.1). Make sure to save changes.*, next hop: mx0.example.com, username/password can be empty, Destination is a regular expression: no, active: yes). This is optional, but will prevent cases, where the mail will cycle between failover servers if there are multiple.data/conf/postfix/extra.cf, you can add bounce_queue_lifetime = 5d (or 3d) to override the default of 1d, which may be a bit short for some use cases. This duration controls how long the failover server will try to forward its mails to the master server, before it gives up and answers with a "message could not be delivered" mail.MooSync can run on any server, also one that is not any of your mail servers. As MooSync can only do its job of syncing data from the master system, it is useless when the master system is down, so you can also just put it on the master system. You can use this docker-compose.yml as a good starting point:
services:
moosync:
image: drmaxnix/moosync
restart: unless-stopped
environment:
SYNC_DESTRUCTIVE: false # you probably want this enabled, but read about the consequences first (see section "Configuration Options")
MASTER_ADDRESS: "mx0.example.com"
MASTER_TOKEN: "<API KEY FOR MASTER SYSTEM>"
SLAVE_ADDRESS_MX1: "mx1.example.com"
SLAVE_TOKEN_MX1: "<API KEY FOR SLAVE SYSTEM MX1>"
SLAVE_ADDRESS_MX2: "mx2.example.com"
SLAVE_TOKEN_MX2: "<API KEY FOR SLAVE SYSTEM MX2>"
# ...
Following configuration options are available by setting environment variables:
| Option | Type | Default | Description |
|---|---|---|---|
| MASTER_ADDRESS🔸 | host/ip | Address of the master mail system | |
| SLAVE_ADDRESS_*🔸 | host/ip | Address of the slave mail system (make sure to use the same option name as for SLAVE_TOKEN_*) | |
| MASTER_TOKEN🔸 | string | API token for master system's Mailcow API | |
| SLAVE_TOKEN_*🔸 | string | API token for slave system's Mailcow API (make sure to use the same option name as for SLAVE_ADDRESS_*) | |
| SYNC_INTERVAL | duration | 15m | How often domain and address configuration should be synced to slave system(s) |
| SYNC_INTERVAL_DKIM | duration | 6h | How often dkim keys should be synced (every domain's key will be synced separately, so this can take some time on systems with many domains) |
| SYNC_DESTRUCTIVE | bool | false | Whether MooSync should clean up everything on the slave system(s) it does not need or know about (⚠️⚠️ READ WARNING BELOW ⚠️⚠️) |
| API_TIMEOUT | int+ | 1000 | HTTP timeout for outgoing API requests to Mailcow (syncs will be aborted when a request ran into a timeout) |
| DOMAIN_WHITELIST_* | domain | empty | When set, only sync this domain (if whitelist is empty, all domains not in blacklist will be synced) |
| DOMAIN_BLACKLIST_* | domain | empty | Do not sync this domain (has precedence over whitelist) |
| DEBUG | bool | false | Whether debug information should be visible in the docker log |
Options marked with
🔸are required; list options need at least one element
Options named
FOO_*can be used multiple times with different value for*; all of its provided values will form a list
Warning
**Destructive Mode:** This mode grants MooSync full control over all slave systems! Don't enable this if you have other domains configured on these systems, as MooSync will happily delete them otherwise! By default (if destructive mode is disabled), MooSync will only add/modify/delete domains, dkim keys and recipient maps for domains allowed by white-/blacklist.
Explanation of types:
| Type | Description | Example(s) |
|---|---|---|
| bool | A boolean value, either true or false | true |
| string | One or more character(s) | TestTest 123 |
| duration | Either a number of seconds, or a number followed by a unit, which can be one of [smhd] for seconds, minutes, hours and days respectively | 15m = 15 minutes = 900 seconds |
| int+ | A positive integer | 42 |
| host/ip | A hostname, domain name, or IPv4/IPv6 address | appapp.example.com198.51.100.492001:db8::a17d:661e |
| domain | A domain name | app.example.com |
Content type
Image
Digest
sha256:d68ff53b7…
Size
9.2 MB
Last updated
11 days ago
docker pull drmaxnix/moosync