Multi-Node Cluster Installation
This guide walks you through installing and configuring a multi-node (multi-pod) hermEX cluster from scratch. You run the same binaries on every server, share control state through a central MariaDB cluster, partition mailboxes across independent backend pods (node_id 0 through 255), and optionally place stateless edge proxy nodes (cluster_edge_only: true) in front.
For a standalone single-server setup, use Single-Node Installation. To convert an existing single-node host into a multi-pod cluster and move populated mailboxes live, see Single-to-Multi Migration. For DRBD/Pacemaker Active-Passive failover pairs and rolling upgrades, continue to HA & Rolling Updates after completing this setup.
1. Cluster Topology and Node Roles
A multi-node cluster separates shared database state from local SQLite WAL mailbox storage:
Internet / Corporate Clients
SMTP(25/465/587) IMAP(993) POP3(995) HTTPS(443)
|
+---------------+---------------+
| Edge Load Balancer / VIP |
| or Stateless Edge Proxy Node |
| (cluster_edge_only: true) |
+---------------+---------------+
|
+------------------------+------------------------+
| Private Cluster Network (10.0.0.0/24) |
v v
+------------------------+ Signed Pod Bridge +------------------------+
| Pod 0 (node_id: 0) | <====================> | Pod 1 (node_id: 1) |
| 10.0.0.10 | /_internal/cluster/ | 10.0.0.11 |
| Local /var/lib/hermex | /_internal/cluster/pod| Local /var/lib/hermex |
| 14 hermex-* daemons | | 14 hermex-* daemons |
+-----------+------------+ +-----------+------------+
| |
+------------------------+------------------------+
|
v
+-----------------------------------------------+
| Shared MariaDB 11.8 Cluster (e.g. Galera) |
| 10.0.0.5:3306 (VIP or HAProxy) |
| Directory, Servers, Relay Spool, ACME, Logs |
+-----------------------------------------------+
| Role | node_id | cluster_edge_only | Stores Mailboxes | Purpose |
|---|---|---|---|---|
| Pod 0 (Primary Default) | 0 | false | Yes (local data_dir) | Holds default mailboxes, node_id: 0 domain stores, and runs hermex-admin serve. |
Backend Pod 1..255 | 1..255 | false | Yes (local data_dir) | Stores mailboxes assigned to its node_id (users.homeserver / domains.homeserver). |
| Stateless Edge Node (Optional) | 0 (or unused) | true | No | Proxies every user session, HTTPS call, and delivery to the owning backend pod. |
Every backend pod (Pod 0, Pod 1, and later pods) already accepts client and SMTP traffic and proxies non-local users to the owning pod transparently. Add dedicated cluster_edge_only: true nodes only when you want stateless DMZ front ends with no local mailbox storage.
2. Prerequisites and Firewall Port Matrix
Prepare the following infrastructure before running commands:
- Shared MariaDB 11.8 cluster: A reachable VIP or proxy endpoint (for example
10.0.0.5:3306), such as a 3-node MariaDB Galera cluster or Managed HA MariaDB. - Two or more Linux servers: Clean RHEL 9 / AlmaLinux 9 / Rocky Linux 9, Debian 12, or Ubuntu 22.04 / 24.04 (
amd64orarm64), minimum 4 GB RAM per backend pod (for ClamAV signatures + 14 daemons). - Private cluster network or VLAN: Dedicated private IP connectivity between MariaDB, every backend pod, and optional edge nodes (examples below use
10.0.0.5for MariaDB,10.0.0.10for Pod 0, and10.0.0.11for Pod 1). - NTP time synchronization: Keep
chronyorsystemd-timesyncdsynchronized across all nodes because signed inter-pod requests validate timestamps within a strict window.
Public Ports (Edge Load Balancer / Front Nodes)
| Port (TCP) | Service | Notes |
|---|---|---|
25 | SMTP | Server-to-server inbound mail |
465 | SMTPS | Implicit TLS mail submission |
587 | SMTP Submission | STARTTLS authenticated submission |
110, 995 | POP3 / POP3S | Standard STARTTLS and implicit-TLS POP3 |
143, 993 | IMAP / IMAPS | STARTTLS and implicit-TLS IMAP |
80, 443 | HTTP / HTTPS | Unified gateway (webmail, EWS, ActiveSync, DAV, JMAP, MAPI/HTTP, MTA-STS, ACME) |
4190 | ManageSieve | Server-side filter management |
Private Cluster Ports (Only Between Cluster Nodes)
| Port (TCP) | servers Column / Setting | Protocol Behavior |
|---|---|---|
3306 | database_dsn / relay_database_dsn | Shared MariaDB cluster |
443 | internal_http_url (--http-url) | Gateway HTTPS handling proxied web/Exchange requests, /_internal/cluster/, and /_internal/cluster/pod/ |
143 | internal_imap_addr (--imap) | Plaintext + STARTTLS IMAP hop (do not point --imap at implicit TLS 993) |
110 | internal_pop3_addr (--pop3) | Plaintext + STLS POP3 hop (do not point --pop3 at implicit TLS 995) |
4190 | internal_sieve_addr (--sieve) | ManageSieve + STARTTLS hop |
25 | internal_smtp_addr (--smtp) / --lmtp | Optional internal SMTP/LMTP hop |
| Custom (Optional) | internal_pod_addr (config.json) | Optional dedicated admin pod bridge listener (otherwise gateway 443 serves /_internal/cluster/pod/) |
Allow TCP 3306 and your internal pod bridge / cluster ports only between your cluster nodes and edge load balancers. Never expose MariaDB 3306 to the public Internet, and configure host firewalls so pods accept inter-pod hops only from trusted cluster IPs.
3. Step 1: Prepare the Shared MariaDB Cluster
If you do not yet have a highly available MariaDB cluster, follow Shared MariaDB 11.8 Cluster to set up a 3-node Galera cluster behind a Keepalived VIP (10.0.0.5:3306) using HAProxy or MaxScale.
On your shared MariaDB cluster (10.0.0.5), create the email database and a cluster database account reachable from every pod subnet (10.0.0.% in this example):
CREATE DATABASE IF NOT EXISTS email
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'hermex'@'10.0.0.%'
IDENTIFIED BY 'REPLACE_WITH_STRONG_DB_PASSWORD';
GRANT ALL PRIVILEGES ON email.* TO 'hermex'@'10.0.0.%';
FLUSH PRIVILEGES;
If you want to isolate high-volume outbound relay spool I/O onto a second MariaDB schema or cluster, create a separate email_relay database and set relay_database_dsn in /etc/hermex/config.json. Leaving relay_database_dsn and log_database_dsn empty ("") shares database_dsn automatically.
4. Step 2: Generate the Six Shared Cluster Secrets
All backend pods and edge nodes in a cluster must share the exact same six cryptographic secrets. Generate them once on an administrative workstation or Pod 0 and record them securely:
for key in webmail_secret admin_secret key_secret digest_secret notify_secret internal_pod_secret; do
printf '"%s": "%s",\n' "$key" "$(openssl rand -hex 32)"
done
| Secret | Purpose Across the Cluster |
|---|---|
webmail_secret | Signs webmail HTTP-only session cookies so clients stay authenticated across pods. |
admin_secret | Signs Admin Panel sessions and tokens. |
key_secret | Encrypts DKIM private keys, TLS keys, and SRS0 tokens in MariaDB (hermex-admin and all pods must match). |
digest_secret | Signs quarantine-digest release links minted by hermex-mta and verified by hermex-webmail. |
notify_secret | Authenticates push wake events stored and relayed through MariaDB. |
internal_pod_secret | Authenticates HMAC-SHA256 front-door HTTP hops, proxy SASL (X-HERMEX-PROXY), /_internal/cluster/, and /_internal/cluster/pod/ with timestamp + single-use nonce replay protection. Required on cluster_edge_only nodes and all multi-pod nodes. |
hermEX refuses to start if any secret equals REPLACE_WITH_A_LONG_RANDOM_STRING or if cluster_edge_only is true while internal_pod_secret is empty.
5. Step 3: Bootstrap Pod 0 (node_id: 0)
Connect to Pod 0 (10.0.0.10) as root and run the standard installer to install binaries, ClamAV, firewall rules, the hermex system user, and all 14 systemd units:
curl -fsSLO https://raw.githubusercontent.com/KilimcininKorOglu/hermEX/main/install.sh
chmod +x install.sh
sudo ./install.sh install --hostname mail.example.com --domain example.com --admin-hostname admin.example.com
Save the printed postmaster@example.com password and /root/hermex-dns-example.txt DNS records.
Because you are connecting Pod 0 to an external shared MariaDB cluster, switch Pod 0 away from its local MariaDB instance cleanly:
- Stop hermEX daemons and disable the local MariaDB service on Pod 0:
sudo systemctl stop hermex.targetsudo systemctl disable --now mariadb.service
- Replace
/etc/hermex/config.jsonon Pod 0 with your cluster configuration (node_id: 0, shareddatabase_dsn, and the six shared secrets generated in Step 2). Keep file mode0640and ownershiproot:hermex:
{
"node_id": 0,
"cluster_edge_only": false,
"database_dsn": "hermex:REPLACE_WITH_STRONG_DB_PASSWORD@tcp(10.0.0.5:3306)/email?charset=utf8mb4",
"relay_database_dsn": "",
"log_database_dsn": "",
"data_dir": "/var/lib/hermex/mail",
"hostname": "mail.example.com",
"admin_hostname": "admin.example.com",
"tls_cert": "/etc/hermex/tls/cert.pem",
"tls_key": "/etc/hermex/tls/key.pem",
"smtp_addr": ":25",
"smtps_addr": ":465",
"submission_addr": ":587",
"pop3_addr": ":110",
"pop3s_addr": ":995",
"imap_addr": ":143",
"imaps_addr": ":993",
"sieve_addr": ":4190",
"gateway_addr": ":443",
"gateway_http_addr": ":80",
"webmail_addr": "127.0.0.1:8601",
"dav_addr": "127.0.0.1:8602",
"activesync_addr": "127.0.0.1:8603",
"ews_addr": "127.0.0.1:8604",
"mapi_addr": "127.0.0.1:8605",
"mta_http_addr": "127.0.0.1:8606",
"notify_addr": "127.0.0.1:8607",
"admin_addr": "127.0.0.1:8608",
"jmap_addr": "127.0.0.1:8609",
"gateway_backend_webmail": "https://127.0.0.1:8601",
"gateway_backend_dav": "https://127.0.0.1:8602",
"gateway_backend_activesync": "https://127.0.0.1:8603",
"gateway_backend_ews": "https://127.0.0.1:8604",
"gateway_backend_mapi": "https://127.0.0.1:8605",
"gateway_backend_mta": "https://127.0.0.1:8606",
"gateway_backend_admin": "https://127.0.0.1:8608",
"gateway_backend_jmap": "https://127.0.0.1:8609",
"notify_url": "https://127.0.0.1:8607",
"webmail_dist": "/opt/hermex/current/webmail",
"acme_storage": "/var/lib/hermex/acme",
"log_spill_dir": "/var/lib/hermex/spill",
"clamd_addr": "unix:///run/clamd.scan/clamd.sock",
"health_addrs": {
"mta": "127.0.0.1:8701",
"imap": "127.0.0.1:8702",
"pop3": "127.0.0.1:8703",
"webmail": "127.0.0.1:8704",
"dav": "127.0.0.1:8705",
"activesync": "127.0.0.1:8706",
"ews": "127.0.0.1:8707",
"mapi": "127.0.0.1:8708",
"notify": "127.0.0.1:8709",
"gateway": "127.0.0.1:8710",
"admin": "127.0.0.1:8711",
"fetchmail": "127.0.0.1:8712",
"sieve": "127.0.0.1:8713",
"jmap": "127.0.0.1:8714"
},
"webmail_secret": "SAME_HEX_SECRET_1",
"admin_secret": "SAME_HEX_SECRET_2",
"key_secret": "SAME_HEX_SECRET_3",
"digest_secret": "SAME_HEX_SECRET_4",
"notify_secret": "SAME_HEX_SECRET_5",
"internal_pod_secret": "SAME_HEX_SECRET_6"
}
clamd_addr socket path by distributionOn RHEL/AlmaLinux/Rocky 9, ClamAV listens at unix:///run/clamd.scan/clamd.sock. On Debian 12 and Ubuntu 22.04/24.04, ClamAV listens at unix:///run/clamav/clamd.ctl. Check the value install.sh originally wrote before overwriting /etc/hermex/config.json.
- Initialize the schema on the shared MariaDB cluster, recreate the primary domain and
postmasteraccount in the shared database, start all 14 services on Pod 0, and verify health:sudo chown root:hermex /etc/hermex/config.jsonsudo chmod 0640 /etc/hermex/config.jsonsudo hermex-admin ensure-schemasudo hermex-admin create-domain example.comsudo hermex-admin create-user postmaster@example.com 'CHANGE_TO_STRONG_PASSWORD' --name="Postmaster"sudo hermex-admin provision-mailboxessudo systemctl start hermex.targetsudo hermex-admin status
Confirm all targets report Up before adding Pod 1.
6. Step 4: Install Additional Backend Pods (node_id: 1..255)
Connect to Pod 1 (10.0.0.11) as root.
-
Run
install.shwithout creating a duplicate domain:curl -fsSLO https://raw.githubusercontent.com/KilimcininKorOglu/hermEX/main/install.shchmod +x install.shsudo ./install.sh install --hostname mail.example.com --domain "" --admin-hostname admin.example.com -
Stop hermEX daemons on Pod 1 and disable its unused local MariaDB server:
sudo systemctl stop hermex.targetsudo systemctl disable --now mariadb.service -
Copy
/etc/hermex/config.jsonfrom Pod 0 to Pod 1, preserving0640 root:hermexpermissions, and change only:"node_id": 1(each backend pod must have a unique integer ID from0to255).- Optionally
"internal_pod_addr"if you bind a dedicated inter-pod admin bridge port instead of routing through Gateway:443. - Keep
"data_dir"(and any"data_partitions") identical across pods when you plan to migrate or rebalance mailboxes, while keeping each pod's disk strictly local (never NFS/CIFS/shared NAS).
-
Start Pod 1 and verify health:
sudo chmod 0640 /etc/hermex/config.jsonsudo chown root:hermex /etc/hermex/config.jsonsudo systemctl start hermex.targetsudo hermex-admin status -
Repeat this step for Pod 2 (
node_id: 2), Pod 3 (node_id: 3), and any further pods. Background workers (scheduled send-later, digest emails, recoverable dumpster retention, push poller, and fetchmail) automatically restrict execution to mailboxes matching their localnode_id.
7. Step 5 (Optional): Install Stateless Edge / Front-Door Nodes (cluster_edge_only: true)
If you want dedicated stateless DMZ front-end nodes that store zero local mailboxes and proxy all connections (including node_id: 0 accounts) to backend pods (see Stateless Edge Proxy Node for full firewall, VIP, and verification steps):
- Run the same installation and disable local MariaDB on the edge node.
- Set these fields in the edge node's
/etc/hermex/config.json:Keep{"node_id": 0,"cluster_edge_only": true,"database_dsn": "hermex:REPLACE_WITH_STRONG_DB_PASSWORD@tcp(10.0.0.5:3306)/email?charset=utf8mb4","data_dir": "/var/lib/hermex/mail","internal_pod_secret": "SAME_HEX_SECRET_6"}"data_dir"pointing to an existing local directory for runtime control/cache paths and leave all six secrets identical to Pod 0. - Open private firewall ports from the edge node's IP to every backend pod's
internal_http_url(443),internal_imap_addr(143),internal_pop3_addr(110),internal_sieve_addr(4190), andinternal_smtp_addr(25).
8. Step 6: Register Pods in the servers Registry
Every daemon refreshes the servers table from MariaDB every 15 seconds (plus cooldown refreshes on cache miss) without restarting.
Run these commands once on Pod 0 (or any host running hermex-admin against the shared database):
# Update Pod 0 (primary default pod)
sudo hermex-admin update-server 0 \
--name=pod-0 \
--hostname=pod0.internal \
--http-url=https://10.0.0.10:443 \
--imap=10.0.0.10:143 \
--pop3=10.0.0.10:110 \
--sieve=10.0.0.10:4190 \
--smtp=10.0.0.10:25 \
--default=on \
--enabled=on \
--weight=100
# Register Pod 1
sudo hermex-admin create-server 1 pod-1 \
--hostname=pod1.internal \
--http-url=https://10.0.0.11:443 \
--imap=10.0.0.11:143 \
--pop3=10.0.0.11:110 \
--sieve=10.0.0.11:4190 \
--smtp=10.0.0.11:25 \
--default=off \
--enabled=on \
--weight=100 \
--notes="backend pod 1"
Verify the registered cluster nodes:
sudo hermex-admin list-servers
sudo hermex-admin show-server 1
You can manage the same registry in two other interfaces:
- Admin Panel UI: Navigate to System -> Servers to list, add, edit, disable, or delete server entries.
- MCP Tools: Use
list_servers,show_server,create_server,update_server, anddelete_server.
- Valid server IDs range from
0to255. - Primary node
0cannot be deleted, and any node still referenced bydomains.homeserverorusers.homeservercannot be deleted until accounts and domains are reassigned. - Disable maintenance nodes safely by setting
--enabled=off(or unchecking Enabled in System -> Servers).
9. Step 7: Assign Domains and Users to Pods (homeserver)
Accounts inherit their domain's homeserver by default when created, or override it per user.
Assign a Domain's Default Pod
New accounts in the domain and the domain's Public Folder store live on the domain's assigned homeserver:
# Option 1: Dedicated command
sudo hermex-admin set-domain-homeserver example.com 1
# Option 2: Via update-domain
sudo hermex-admin update-domain example.com --homeserver=1
In the Admin Panel, open Directory -> Domains -> <domain> -> General and select Default homeserver.
Assign or Create Individual Users on Specific Pods
# Create Alice on Pod 0 (override domain default)
sudo hermex-admin create-user alice@example.com 'StrongPass!Alice1' --name="Alice Kaya" --homeserver=0
# Create Bob on Pod 1
sudo hermex-admin create-user bob@example.com 'StrongPass!Bob1' --name="Bob Demir" --homeserver=1
# Provision mailboxes (remote pods receive provisioning calls through the signed pod bridge)
sudo hermex-admin provision-mailboxes
To change a user's homeserver field via CLI or Admin Panel:
sudo hermex-admin update-user bob@example.com --homeserver=1
In the Admin Panel, open Directory -> Users -> <user> -> Homeserver.
homeserver on an active populated mailbox without moving its dataChanging users.homeserver immediately routes traffic to the new pod. Only reassign an empty account before first mail delivery, or use live pod_move (POST /admin/migrations/pod-move, Admin UI, CLI hermex-admin move-mailbox, or MCP move_mailbox) documented in Single-to-Multi Migration to transfer populated mailbox data safely.
10. Step 8: Front-End Load Balancing, DNS, and Shared TLS (ACME)
Choose one of the three complete ingress configurations depending on your availability needs: DNS Round-Robin (No Extra Proxy), Stateless Edge Proxy Node (cluster_edge_only: true), or L4 TCP Load Balancer (HAProxy, Envoy, Keepalived VIP, or Cloud NLB).
Point public DNS (mail.example.com, admin.example.com, autodiscover.example.com, autoconfig.example.com, mta-sts.example.com, and domain MX records) to your edge load balancer VIP (HAProxy, Envoy, Keepalived, or Round-Robin edge nodes).
- Layer-4 TCP Passthrough Recommended: Forward TCP ports
443,80,25,465,587,143,993,110,995, and4190at L4 so hermEX's gateway handles TLS-ALPN-01 ACME (443), SNI certificate matching, and protocol banners directly. - Shared ACME Certificates: Because hermEX stores issued Let's Encrypt certificates and keys in MariaDB (encrypted with
key_secret), any pod or edge node completing the ACME challenge makes the certificate available to all nodes across the cluster within the 15-second TLS provider poll window. - Cloudflare Proxy Rule: Keep Cloudflare proxy disabled (DNS only / gray cloud) on all mail hostnames so direct SMTP, IMAPS, POP3S, and TLS-ALPN-01 work cleanly.
11. Step 9: Cluster-Wide Admin Operations and Backups
Once servers and internal_pod_secret are configured across pods:
- Single-user CLI and Admin Panel actions route transparently:
check-mailbox alice@example.com,move-mail, quarantine list/release/delete, mailbox store tabs,backup-mail alice@example.com /backup, and MBOX/PST export and import forward automatically to the owning pod over/_internal/cluster/pod/. - Cluster-wide maintenance fans out across enabled pods:
# Check every mailbox on every enabled podsudo hermex-admin check-mailbox all# Back up all pods (writes per-pod streaming tar archives: pod-0.tar.gz, pod-1.tar.gz, ...)sudo hermex-admin backup-mail all /var/backups/hermex-mail# Retrain global Bayes spam model across all pods and merge tokenssudo hermex-admin retrain-bayes
- Single database backup per cluster: Run
sudo hermex-admin backup-dbon one administrative node (and snapshot/etc/hermex/config.jsonsecurely offline).
12. Step 10: End-to-End Cluster Verification Checklist
Verify every layer before putting production domains onto the cluster:
- Daemon health on every node: Run
sudo hermex-admin statuson Pod 0, Pod 1, and any edge nodes and confirm all 15 targets reportUpon the exact same build version. - Server registry check: Run
sudo hermex-admin list-serversand confirm every pod showsenabled=trueand accurate internal endpoints (--http-url,--imap,--pop3,--sieve,--smtp). - Signed pod-bridge security check (expect HTTP
403): From an external client or pod without valid HMAC headers, confirm internal cluster endpoints reject unauthenticated requests with403 Forbidden:Both commands must printcurl -sk -o /dev/null -w '%{http_code}\n' -X POST https://mail.example.com/_internal/cluster/pod/photocurl -sk -o /dev/null -w '%{http_code}\n' -X POST https://mail.example.com/_internal/cluster/deliver403. - Cross-pod mail flow: Send an email from
alice@example.com(Pod 0) tobob@example.com(Pod 1) and verify delivery in Bob's Inbox. - Cross-pod front-door proxy: Connect an IMAP client (port
993), POP3 client (port995), ManageSieve client (port4190), and browser Webmail session (https://mail.example.com) to Pod 0's gateway/listeners asbob@example.com(whose mailbox lives on Pod 1) and confirm login, folder listing, and message reading succeed transparently. - Cross-pod collaboration: Grant
bob@example.comdelegate and Send-As permissions onalice@example.com, send a message as Alice from Bob's Webmail session, confirm Sent-Copy lands in Alice's Sent folder on Pod 0, and verify domain Public Folder visibility for both users. - Cluster maintenance check: Run
sudo hermex-admin check-mailbox alland confirm healthy verification across both Pod 0 and Pod 1 without errors. Clean up any temporary test accounts before production launch.
Next Step
Configure organizations, branding, distribution groups, rooms, delegates, and public folders using Quick Exchange Setup, then review HA & Rolling Updates to add Active-Passive DRBD/Pacemaker failover per pod and plan zero-downtime upgrades.