Skip to main content

Ingress Option 2: hermEX Stateless Edge Proxy (cluster_edge_only: true)

Instead of managing third-party proxy software in a DMZ, you can run dedicated stateless hermEX front-door edge nodes by setting "cluster_edge_only": true in /etc/hermex/config.json. An edge node opens public ports (25, 80, 110, 143, 443, 465, 587, 993, 995, 4190), stores zero local mailboxes, and proxies every client connection and SMTP delivery directly to the owning backend pod (Pod 0, Pod 1, ... Pod N) over the private cluster network.


1. Architecture Overview​

Internet / Corporate Clients
SMTP(25/465/587) IMAP(993) POP3(995) HTTPS(443)
|
+--------------+--------------+
| Keepalived VIP (Optional) |
| 203.0.113.50 |
+--------------+--------------+
/ \
v v
+--------------------+ +--------------------+
| Edge 1 (DMZ) | | Edge 2 (DMZ) |
| cluster_edge_only: | | cluster_edge_only: |
| true | | true |
| 0 Mailboxes stored | | 0 Mailboxes stored |
+---------+----------+ +---------+----------+
\ /
\ Private VLAN 10.0.0.0/24/
+---------+-----------+-----------+---------+
v v
+------------------+ +------------------+
| Pod 0 (node_id 0)| | Pod 1 (node_id 1)|
| 10.0.0.10 | | 10.0.0.11 |
| Local Mailboxes | | Local Mailboxes |
+--------+---------+ +--------+---------+
\ /
+-------------------+--------------------+
v
Shared MariaDB VIP 10.0.0.5

How cluster_edge_only: true Works Inside hermEX​

  • In cluster.Router.IsLocal(), when cluster_edge_only is true, no node ID is treated as local (including node_id: 0).
  • Every protocol daemon (gateway, imap, pop3, sieve, mta) resolves the target user's homeserver from MariaDB users/domains and forwards the session using signed internal hops (X-Hermex-Internal-Auth for HTTP, X-HERMEX-PROXY SASL for IMAP/POP3/ManageSieve, and remote pod bridge / SMTP for mail delivery).
  • hermex-admin enforces at startup that cluster_edge_only: true requires a non-empty internal_pod_secret matching the backend pods.
  • Because cluster_edge_only nodes store no mailboxes, do not register edge nodes as mailbox backend targets in the MariaDB servers table. Only backend storage pods (0..255) belong in servers.

2. Firewall Ports for Edge Nodes​

DirectionPort (TCP)Source / Destination
Inbound to Edge (Public)25, 80, 110, 143, 443, 465, 587, 993, 995, 4190Internet / Corporate Mail Clients
Edge -> Shared MariaDB3306Edge Private IP (10.0.0.15) -> 10.0.0.5
Edge -> Every Backend Pod443 (internal_http_url), 143 (internal_imap_addr), 110 (internal_pop3_addr), 4190 (internal_sieve_addr), 25 (internal_smtp_addr)Edge Private IP -> Pod Private IPs (10.0.0.10, 10.0.0.11, ...)
Edge <-> Edge (optional VIP)protocol 112 (VRRP)edge-1 (10.0.0.15) and edge-2 (10.0.0.16)
Keep Admin Panel (admin_hostname) private or IP-restricted on Edge nodes

Only run hermex-admin serve on your administrative pod or protect admin.example.com with strict IP allowlists / VPN access. Backend pods should only accept internal cluster ports from trusted Edge and cluster IPs.


3. Step-by-Step Edge Node Installation​

Run these steps on edge-1 (10.0.0.15, public 203.0.113.20) and optionally edge-2 (10.0.0.16, public 203.0.113.21):

  1. Install hermEX binaries without bootstrapping a duplicate database domain:
    curl -fsSLO https://raw.githubusercontent.com/KilimcininKorOglu/hermEX/main/install.sh
    chmod +x install.sh
    sudo ./install.sh install --hostname mail.example.com --domain "" --admin-hostname admin.example.com
  2. Stop the services and disable the unused local MariaDB instance on the edge node:
    sudo systemctl stop hermex.target
    sudo systemctl disable --now mariadb.service
  3. Ensure an empty local directory exists for runtime lock/spill paths (data_dir) and synchronize system clocks (chrony or systemd-timesyncd).
  4. Replace /etc/hermex/config.json on edge-1 with a configuration pointing to the shared MariaDB cluster and sharing all six identical secrets from Pod 0:
    {
    "node_id": 0,
    "cluster_edge_only": true,
    "database_dsn": "hermex:REPLACE_STRONG_DB_PASSWORD@tcp(10.0.0.5:3306)/email?parseTime=true&multiStatements=true",
    "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"
    }
    (On Debian/Ubuntu, verify "clamd_addr" matches unix:///run/clamav/clamd.ctl.)
  5. Lock permissions and start the edge services:
    sudo chmod 0640 /etc/hermex/config.json
    sudo chown root:hermex /etc/hermex/config.json
    sudo systemctl start hermex.target
    sudo hermex-admin status

4. Optional High-Availability VIP Between Two Edge Nodes (Keepalived)​

If you run two edge nodes (edge-1 and edge-2), share a public VIP (203.0.113.50) using Keepalived or place a cloud L4 load balancer in front of edge-1 and edge-2.

Create /usr/local/bin/check_hermex_edge.sh on both edge nodes (chmod +x):

#!/bin/bash
set -euo pipefail
curl -sf http://127.0.0.1:8710/healthz >/dev/null
curl -sf http://127.0.0.1:8701/healthz >/dev/null

Example /etc/keepalived/keepalived.conf on edge-1 (MASTER, priority 150; use BACKUP, priority 100, swapped IPs on edge-2):

vrrp_script chk_hermex_edge {
script "/usr/local/bin/check_hermex_edge.sh"
interval 2
fall 2
rise 2
}

vrrp_instance VI_HERMEX_EDGE {
state MASTER
interface eth0
virtual_router_id 61
priority 150
advert_int 1
unicast_src_ip 203.0.113.20
unicast_peer {
203.0.113.21
}
authentication {
auth_type PASS
auth_pass REPLACE_EDGE_VRRP_SECRET
}
virtual_ipaddress {
203.0.113.50/24 dev eth0
}
track_script {
chk_hermex_edge
}
}

Enable net.ipv4.ip_nonlocal_bind = 1 in /etc/sysctl.d/90-vip-bind.conf (sudo sysctl -p) and start Keepalived (sudo systemctl enable --now keepalived).

Outbound mail SPF & PTR for Edge nodes

If edge hermex-mta workers claim outbound messages from the shared MariaDB relay_messages spool and send directly to external MX servers, add the edge public IPv4 addresses to your SPF record and configure matching PTR records (mail.example.com) for every edge public IP. Alternatively, disable smtp_addr outbound relay or route outbound mail through a dedicated smarthost if only backend pods hold outbound PTR records.


5. Verification​

# 1. Confirm all 15 edge daemons are Up
sudo hermex-admin status

# 2. Confirm zero local mailbox directories exist on the edge node
ls -la /var/lib/hermex/mail/user 2>/dev/null || echo "OK: no local user mailboxes"

# 3. Verify edge node is NOT listed in backend servers table (only storage pods belong there)
sudo hermex-admin list-servers

# 4. Verify client connections through the edge IP reach mailboxes on Pod 0 and Pod 1
openssl s_client -connect 203.0.113.20:993 -servername mail.example.com -quiet </dev/null