TRINITY logoTRINITYVDI

TRINITY VDI / Documentation / 7. ntfy servers

7. ntfy servers (phone notifications)

Run two self-hosted ntfy servers with keepalived and a virtual IP for TRINITY phone notifications: TLS, users, access tokens, health check and failover.

Download the packages
Documentation pages

The TRINITY phone app receives alerts through an ntfy server: the portal sends the open alerts out to it, end-to-end encrypted per phone, and the phone reads them there, so the portal needs no inbound port. Use https://ntfy.sh for a few phones, or this pair of your own, published on the internet.

7.1 Files (ntfy01, ntfy02)

The pair uses the keepalived helper of the connection server package for its VIP. Copy TRINITY-ConnServer-1.2.1-Linux.tar.gz with the checksum list to both (2.5), and from trinity01 the certificate:

cd ~/certs && for ip in 30 31; do scp ntfy.crt ntfy.key corp-root.crt 10.0.10.$ip: ; done

7.2 Install and configure (both nodes)

sudo apt install -y ntfy keepalived
sudo install -d -o _ntfy -g _ntfy -m 750 /var/lib/ntfy /var/cache/ntfy
sudo install -o root -g _ntfy -m 640 ~/ntfy.crt /etc/ntfy/tls.crt
sudo install -o root -g _ntfy -m 640 ~/ntfy.key /etc/ntfy/tls.key && rm ~/ntfy.key
sudo tee /etc/ntfy/server.yml >/dev/null <<'EOF'
base-url: "https://ntfy.example.com"
listen-https: ":443"
key-file: "/etc/ntfy/tls.key"
cert-file: "/etc/ntfy/tls.crt"
cache-file: "/var/cache/ntfy/cache.db"
cache-duration: "12h"
auth-file: "/var/lib/ntfy/user.db"
auth-default-access: "deny-all"
enable-login: true
enable-signup: false
visitor-request-limit-exempt-hosts: "10.0.10.33,10.0.10.34,10.0.10.36"
EOF
sudo install -d /etc/systemd/system/ntfy.service.d
printf '[Service]\nAmbientCapabilities=CAP_NET_BIND_SERVICE\n' | sudo tee /etc/systemd/system/ntfy.service.d/bind-443.conf
sudo systemctl daemon-reload && sudo systemctl enable ntfy && sudo systemctl restart ntfy
curl -sk https://127.0.0.1/v1/health; echo

7.3 User and token (ntfy01), same users on ntfy02

The portal writes and reads topics named mws-*. On ntfy01:

sudo -u _ntfy ntfy user add trinity
sudo -u _ntfy ntfy access trinity 'mws-*' read-write
sudo -u _ntfy ntfy token add --label trinity-relay trinity      # keep the token: the portal needs it
sudo systemctl stop ntfy
sudo install -m 600 -o $USER /var/lib/ntfy/user.db ~/user.db
sudo systemctl start ntfy
scp ~/user.db 10.0.10.31: && rm ~/user.db

On ntfy02:

sudo systemctl stop ntfy
sudo install -o _ntfy -g _ntfy -m 600 ~/user.db /var/lib/ntfy/user.db && rm ~/user.db
sudo systemctl start ntfy && sudo -u _ntfy ntfy user list

7.4 Firewall and VIP

On both nodes:

sudo ufw allow 443/tcp
sudo ufw allow from 10.0.10.31 proto vrrp      # on ntfy01
sudo ufw allow from 10.0.10.30 proto vrrp      # on ntfy02
cd ~ && tar xzf TRINITY-ConnServer-1.2.1-Linux.tar.gz connsrv/trinity-keepalived.sh
sudo tee /usr/local/bin/ntfy-check >/dev/null <<'EOF'
#!/bin/sh
curl -fsk --max-time 4 https://127.0.0.1/v1/health | grep -q '"healthy":true'
EOF
sudo chmod 755 /usr/local/bin/ntfy-check && sudo /usr/local/bin/ntfy-check && echo healthy
sudo install -d /etc/keepalived

On ntfy01 (priority 150), which makes the VRRP password and hands it to ntfy02:

IF=$(ip -o -4 route show to default | awk '{print $5}' | head -n1)
sudo sh -c 'umask 077; openssl rand -base64 24 | tr -dc A-Za-z0-9 | head -c 8 > /etc/keepalived/ntfy-vrrp.secret'
sudo bash ~/connsrv/trinity-keepalived.sh --instance TRINITY_NTFY --vip 10.0.10.32/24 --interface $IF \
  --peers 10.0.10.31 --priority 150 --vrid 54 --check /usr/local/bin/ntfy-check --secret-file /etc/keepalived/ntfy-vrrp.secret
sudo install -m 600 -o $USER /etc/keepalived/ntfy-vrrp.secret ~/ntfy-vrrp.secret
scp ~/ntfy-vrrp.secret 10.0.10.31: && rm ~/ntfy-vrrp.secret

On ntfy02 (priority 140):

IF=$(ip -o -4 route show to default | awk '{print $5}' | head -n1)
sudo install -o root -g root -m 600 ~/ntfy-vrrp.secret /etc/keepalived/ntfy-vrrp.secret && rm ~/ntfy-vrrp.secret
sudo bash ~/connsrv/trinity-keepalived.sh --instance TRINITY_NTFY --vip 10.0.10.32/24 --interface $IF \
  --peers 10.0.10.30 --priority 140 --vrid 54 --check /usr/local/bin/ntfy-check --secret-file /etc/keepalived/ntfy-vrrp.secret

7.5 Check and switch the relay on

sudo cat /run/trinity-cluster/TRINITY_NTFY.state        # MASTER on one node, BACKUP on the other
curl -s https://ntfy.example.com/v1/health; echo         # from trinity01, after chapter 11

In the portal: Admin > Settings > Integrations > Phone relay (L4): On, address https://ntfy.example.com, the access token of 7.3, Save, Test. Phones paired before must be paired again (Monitoring > Devices & settings > Notifications).

Names, addresses and accounts in the examples (corp.example.com, 10.0.x.x, CORP\…) are examples: use your own. TRINITY 1.2.1, December 2026.