Fly.io
Fly.io runs the server for you, with HTTPS included. One script sets it up. Fly stops the server while no device is connected and starts it on the next connection.
Set up
Install
flyctland runfly auth login.From a clone of this repository, run the script with an app name of your choice. Fly's names are global, so pick one nobody has:
shscripts/deploy-fly.sh <app>It creates the app, its volume and the server password where they are missing, deploys, and checks the server answers. On macOS the password goes to the Keychain (service "Annoto sync"); elsewhere it is printed once.
Open
https://<app>.fly.devand create the vault.
Run the script again to update the server. Logs: fly logs --app <app>.
A private server
scripts/deploy-fly.sh --private <app> releases the public addresses and keeps the app on your Fly organization's private network, which devices join with WireGuard. Let's Encrypt cannot reach a private server, so Caddy in the image gets the certificate through a DNS challenge at your DNS provider:
- Pick a name on a domain you own, and the Caddy module of its DNS provider (
cloudflare,route53,porkbun, …: see https://github.com/caddy-dns). No API at your DNS provider, or no wish to keep its keys on the server: useacmednsinstead. Register once at an acme-dns server (curl -X POST https://auth.acme-dns.io/register, or your own instance) and add by hand one CNAME,_acme-challenge.<your name>to thefulldomainit returns. The server then holds keys that change only that challenge record, and certificates renew on their own. - Copy that provider's block from its module's README into a file, with your API keys, stage it as a secret and delete the file:
fly secrets set --app <app> --stage ACME_DNS="$(cat acme-dns.txt)". - Run
ANNOTO_DOMAIN=notes.example.org CADDY_DNS=<module> scripts/deploy-fly.sh --private <app>. - Add the AAAA record the script prints: your name, pointing to the app's private (Flycast) address. A device that looked the name up before the record existed may remember "not found" for up to your zone's negative TTL: wait, or flush its DNS cache.
- On each device:
fly wireguard create <org> <region> <device> <device>.conf, import the file in the WireGuard app, and keep the tunnel on while Annoto syncs. The tunnel reaches every app of that Fly organization: give Annoto its own organization to keep it apart. - In Annoto, Settings › Sync, use
https://notes.example.org. A device that syncs already: Disconnect, connect to the new address, and reconnect with the passphrase.