Files
EasyDNS-Web/MULTI-SERVER.md
T
Mateusz Gruszczyński a28362b82c
Go quality gates / test (push) Waiting to run
v0.1.2
2026-12-01 00:16:15 +01:00

130 lines
14 KiB
Markdown

# Optional multi-server management
## Purpose
EasyDNS Web can manage several **independent** EasyDNS Rust server installations from one Go panel. It is designed for operators who run a Primary DNS server and one or more Secondary DNS servers but want a single administration entry point.
The feature is **off by default**. On Debian, set `[multiserver] enabled = true` in `/etc/easydns-ui/config.toml`; on Docker Compose, set `EASYDNS_UI_MULTISERVER=true` in `.env`, then restart the panel. If neither setting exists, an optional toggle is available in Configuration. When TOML or the environment explicitly defines the mode, the toggle is hidden.
This is not a native EasyDNS cluster. The panel does **not** implement cluster membership, distributed state, leader election, quorum, DNS zone replication, automatic synchronization, transfer ACL management or token provisioning. Primary/Secondary labels are only operator-defined presentation metadata; actual per-zone roles come from EasyDNS.
## Topology example
```text
EasyDNS Web (Go)
port 8088
|
+--------------+--------------+
| | |
local API remote HTTPS remote HTTPS
| | |
dns-primary-01 dns-secondary-01 dns-secondary-02
label: Primary label: Secondary label: Secondary
Native DNS AXFR/IXFR/NOTIFY relationships are configured
on the EasyDNS services, outside the panel.
```
## Getting started
1. Configure the DNS servers first. Ensure each EasyDNS REST API is accessible from the machine hosting the panel.
2. Enable Multi-server in TOML or Compose `.env` and restart. For installs with no explicit `enabled` setting, use **Configuration → Enable multi-server management** instead.
3. The **Servers** entry appears in the sidebar and the active-server selector appears in the top bar.
4. Open **Servers → Add server** and supply a descriptive name, a UI role label, a base URL, and that server's own generated `control.token`.
5. Repeat for other installations. The local server is already managed, so in a 1 Primary + 2 Secondary topology only **two remote entries** need to be added.
6. The Servers page shows each server's live health, status and actual zone-role counts. Click **Manage server** or use the top-bar selector to switch all standard pages to that server.
7. Select **Compare zone serials**, enter a zone FQDN (e.g. `example.com.`) and inspect the SOA serial and presence returned by each server. The comparison uses the node marked Primary as the reference, if present.
### Switching the active server
Use the **SERVER** dropdown in the top toolbar, or click **Manage server** / **Open** in the Servers view. The dropdown automatically submits a CSRF-protected form when its value changes. There is no separate **Switch** button. Automatic selection requires JavaScript, loaded from an external script compatible with the panel's strict Content Security Policy (CSP).
After switching, the panel reloads from the newly selected EasyDNS API. A compact **ACTIVE SERVER** bar shows the chosen server's name, configured API address and topology label. **Overview, Zones, DNS records, DNS lookup, Upstreams, Policies, Cache, Audit and Server status show only the selected server's data. All write actions target that same server.** Metrics can optionally show the selected server or compare all registered servers, as described below. The top-level Servers page and the zone comparison screen intentionally display multiple servers.
When switching from a zone details page, the panel returns to **Zones**, because that zone or record may not exist on the newly selected server. Switch back to Local EasyDNS to manage the local installation again. A stale or removed server selection is rejected; the panel will **never** silently execute a write on the local server instead.
If switching seems ineffective, verify the **ACTIVE SERVER** name and API URL above the content, reload `/zones`, and check each node's health on the Servers page. Browser assets are revalidated after an update. A remote node must accept its own generated bearer token; successful health checks alone do not prove authorization for zone endpoints.
### Metrics display modes
When at least two servers are registered and Multi-server management is enabled, open **Metrics**. A compact selector above the charts provides three modes:
| Mode | Scope | What is shown |
|---|---|---|
| **Aggregate** (default) | All registered servers | Sum of counter deltas (query QPS, response QPS, blocked QPS) and of cumulative counters from responding nodes; weighted fleet cache hit ratio; **per-server** p95 lines (percentiles cannot be summed). |
| **Split** | All registered servers | A separate colored line for every server on the same chart axes, a server-by-server stats table, per-server p95 chart and latency breakdown. |
| **Single** | The active server in the top selector | The original EasyDNS Metrics page, with only that server's statistics and history. |
The selected mode is remembered in a browser cookie and can be changed by clicking the three mode tabs (no JavaScript needed for the mode links). The **active-server selector** remains independent and controls DNS management pages and the Metrics **Single** mode only. In Aggregate/Split a **FLEET METRICS** scope strip replaces the single-node context line so the data's origin is unambiguous.
Only the existing `GET /api/v1/stats` endpoint is used. The Go panel polls each enabled server every 15 seconds and stores up to 1,440 real observations (six hours) **per node in RAM**. The authenticated panel-only `GET /ui/telemetry?mode=aggregate|split` provides chart data; it is not an EasyDNS endpoint. On startup/restart, the panel has no historical samples until it has collected new readings.
**Aggregation rules:**
- QPS and response/blocked rates are obtained from counter differences divided by actual elapsed seconds. Aggregate plots add rates across nodes **only if every registered node has a fresh, valid sample**. Readings are aligned to UTC 15-second slots with a 23-second maximum age. Missing/offline nodes, counter resets and stale samples create `null` gaps, never an invented zero or reduced fleet total.
- The cache ratio is not an average of percentages: it is `sum(hit_rate) / (sum(hit_rate) + sum(miss_rate))`, where hit/miss rates are derived from native cache counters. Other percentages and latency percentiles are **not** added together. The latency p95 chart uses one series per node, including in Aggregate mode.
- The top summary sums current cumulative counters of **responding** servers. These counters are counted since each individual EasyDNS process started; they are **not** a shared 24-hour measurement. If one node cannot be reached, the UI reports `X / Y responding`, labels totals as partial and preserves gaps on the aggregate rate charts.
- Split mode draws individual node histories with gaps; old samples are not extended beyond their actual timestamps. The panel does not deduplicate a DNS query that happens to be counted by different servers.
If the option is disabled, the standard single-server Metrics page remains exactly as before. The modes do not alter EasyDNS DNS configuration, replication or control tokens.
To disable it, change the explicitly configured TOML or `.env` flag to `false` and restart. When there is no explicit flag, uncheck Enable in Configuration. The Servers navigation and selector disappear, and requests return to the local EasyDNS instance. Panel-added remote connections remain saved for later re-enabling. To permanently remove one of those connections and its token, use **Servers → Remove** with name confirmation. Configuration-managed server entries cannot be removed from the web UI.
**Managed labels:** the Servers inventory marks the panel host `LOCAL` and each other connection `REMOTE`. A role label defined by TOML/`.env` is displayed as read-only text; no inactive editing form or configuration-source badge appears. UI-added remote nodes still have working role-edit and Remove controls. A local role explicitly set in TOML/`.env` is read-only.
## What is shown
| UI element | Data source / behavior |
|---|---|
| Node name, Primary/Secondary/Unassigned label | Supplied in TOML/`.env` or stored for UI-managed nodes in `nodes.json`; no DNS mutation |
| Health, offline/degraded | Each node's real `GET /api/v1/health` and `GET /api/v1/status` |
| Version, mode, real primary and secondary zone counts | Individual `GET /api/v1/status` |
| Active server | Panel-managed HTTP-only session-scoped preference cookie; authenticated POST and CSRF |
| SOA serial and loaded/expired state | Individual `GET /api/v1/zones/{zone}` |
| Native zone refresh on a Secondary | The existing `POST /api/v1/zones/{zone}/sync`, available in the selected server's zone operations |
| Serial “matches/differs” | Simple comparison to the panel-labeled Primary node's reported serial; **not** transfer confirmation |
A server can have both primary and secondary zones: the displayed topology label is not a substitute for inspecting its real zone roles. No health information is fabricated if a node cannot be reached.
## Transport and credentials
The local node continues to use the token automatically generated by EasyDNS, typically `/etc/easydns/data/control.token`, or the existing local Unix control socket.
Each remote server has its **own** automatically generated token. Read it securely on that machine and supply it using the one-time Add server form, or configure the token in TOML/`.env`. There is no native EasyDNS endpoint to discover another server's token and no shared cluster secret. Tokens submitted through the panel are stored as private `0600` files under `/var/lib/easydns-ui/tokens/<node-id>.token`; inline TOML/`.env` tokens remain in process memory and are not copied into those files. They never appear in browser HTML, cookies, JavaScript, metrics or logs.
**HTTPS with certificate verification is mandatory for remote network addresses.** For local port forwarding, `http://127.0.0.1:PORT`, `http://[::1]:PORT` or `http://localhost:PORT` is permitted (the loopback address refers to the panel host).
Make sure the remote HTTPS endpoint or tunnel cannot be reached by untrusted clients. Protect the web admin interface with HTTPS or an SSH/VPN tunnel. Because a registered server may be fully managed, every panel administrator effectively has administrative control over all registered EasyDNS installations.
## Panel files and startup behavior
| Path | Purpose / access |
|---|---|
| `/var/lib/easydns-ui/settings.json` | Optional preference for installs without explicit TOML/`.env` enablement; `0600` |
| `/var/lib/easydns-ui/nodes.json` | Node IDs, URLs, labels, local role; **no API tokens**; `0600` |
| `/var/lib/easydns-ui/tokens/*.token` | Independent bearer secrets for remote nodes; `0600` |
| `/etc/easydns-ui/config.toml` | Protected Debian TOML: local/API settings and optional remote tokens or token paths (0640) |
The Debian installer provisions the private state directory for user `easydns-ui` (0700). An explicit TOML `[multiserver].enabled` setting takes precedence over saved preferences, and an explicitly set `EASYDNS_UI_MULTISERVER` environment value overrides TOML. The UI toggle is not rendered and its POST handler refuses changes when either source sets enabled. The default is disabled. Updates preserve private state; package purge removes panel-owned registry files and tokens.
Health checks are performed when the Servers page is visited. The Go process also samples each enabled server's `/stats` counters every 15 seconds and maintains up to 1,440 RAM samples per server; disabled mode stops remote polling. No external database is required.
## Limitations and operational guidance
- No automatic secondary provisioning, replication configuration, transfer scheduling, batch commits, automatic failover, leader election, quorum or consensus.
- No inference that a Primary-to-Secondary link actually exists. The topology connector represents operator intent; it is not a verified transfer graph.
- Zone comparison checks serials and state on demand; it is not a continuous replication monitor. DNS serial arithmetic (RFC 1982) and propagation timing matter.
- Remote credentials can expire or become invalid. The Servers page then shows a failed probe; update a node by removing and re-adding it with a fresh token (the panel does not rotate native EasyDNS credentials).
- The maximum is 15 remote connections plus one local server. An unreachable node does not prevent managing other healthy nodes.
- Disable the feature when not needed. Disabling does not delete credentials; remove connections or purge the package if you want to erase them.
This feature adds panel-owned endpoints such as `/servers`, `/servers/compare` and `/configuration/multi-server`, **not new EasyDNS API endpoints**.
For preconfigured nodes in Debian TOML (`[[servers]]`) or Docker Compose `.env` (`EASYDNS_UI_SERVER_N_TOKEN`), secrets are held in the Go process memory rather than copied to the panel-owned token directory. See [CONFIGURATION.md](CONFIGURATION.md) for examples.
## Server inventory deep links (0.1.2-1)
- Use `/servers#server-inventory` to jump directly to the managed installations list; the Servers page contains a visible shortcut to this section.
- The **View in inventory** action on each topology card points to `/servers#server-{id}` and highlights that server's row. **Server status** also links to the inventory while multi-server is enabled.
- If multi-server is disabled, opening `/servers` redirects to Configuration and displays instructions for enabling it rather than an unexplained 404. Config-managed disabled mode must be changed in TOML/environment, not through the hidden checkbox.