berth

How Berth works

How changes go live

Every configuration change is rendered from the panel database, staged, checked with the service's own config test, swapped in atomically and reloaded, with automatic rollback, quarantine of one customer's broken file and a change log with diffs.

Updated 7 min readconfiguration · validation · rollback · atomic · config test · change log · declarativeView as Markdown

On this page
  1. Desired state, not patches
  2. The five steps
  3. One customer's mistake affects only that customer
  4. The change log
  5. Customising safely
  6. Repairing drift
  7. Why this matters

When you change a PHP version, add an alias or switch on mail for a domain, Berth does not edit configuration files in place. It writes complete files from the desired state in the panel database, tests them with the service's own checker, and only then makes them live. A change that does not pass is rolled back before any service sees it. This article explains that pipeline, what happens when one customer's file breaks, and where you can see every change afterwards.

Desired state, not patches

The panel database holds what the server should look like: domains, aliases, certificates, PHP settings, mailboxes, DNS records. Configuration files are always rendered in full from that state, through templates that have golden-file tests. Berth does not patch lines in the files it owns, so there is no drift between "what the panel thinks" and "what is on disk" that builds up over time. If someone does edit a rendered file by hand, the next apply or berth repair --areas config simply writes the correct version again. The one exception is Postfix, which has no include mechanism: a hoster's own additions set parameters from a fixed list with postconf -e, still tested and rolled back on failure.

Rendered files live under /etc/berth/rendered/, one directory per service (and per PHP version for PHP-FPM). Each service's own configuration contains only a small include file that points there, so the distribution's packaged config stays intact. Your own additions go in /etc/berth/local/, which Berth includes but never overwrites. See On-disk layout.

You can also edit those additions in the panel, under System → Configuration (berth system local-config): one managed addition per service (nginx, Apache, PHP-FPM per version, Postfix, Dovecot, MariaDB, sysctl, journald and logrotate). Berth refuses directives that would let a program run as root. Each change runs through the service's own test and goes back automatically unless you confirm within a few minutes that the service still runs and answers. Earlier versions can be applied again, and a hand edit on disk can be adopted as the new addition.

For the web server virtual hosts and PHP-FPM pools, the agent renders the files itself from typed specifications instead of receiving finished text from the panel, and binds paths, sockets and the run-as user to the subscription the request is for. See Architecture.

The five steps

Every apply is a small transaction carried out by the root agent:

  1. Stage. The new files are written next to the current ones under a temporary name that the service's include patterns do not read. The old content is kept for the diff.
  2. Swap. The new files replace the old ones with an atomic rename, and the previous version of each file is kept. A reader sees either the old file or the new one, never half of each.
  3. Test. The OS adapter runs the service's own configuration test against the full configuration:
ServiceTest
nginxnginx -t
Apacheapache2ctl configtest (Debian, Ubuntu) or httpd -t (AlmaLinux, Rocky)
PHP-FPMphp-fpm -t, separately for each subscription's own FPM
Postfixpostfix check
Dovecotdoveconf -n, with Sieve scripts compiled before they are put in place
BINDnamed-checkzone, per zone
  1. Roll back on failure. If the test fails, the previous files go back and the service is not reloaded. The change is reported as failed with the test output; nothing live has changed.
  2. Reload. If the test passes, the service is reloaded in a safe order; PHP-FPM reloads let running requests finish. nginx is restarted instead when a change alters its shared memory zones (rate-limit or cache zones), which a reload cannot take over, and after every nginx reload Berth checks that the new configuration was really accepted, restarting nginx if it was silently refused.

Only one apply runs per service at a time, including applies started by timers and by berth repair, so two changes can never see each other's half-swapped files.

Batched tests for busy servers

nginx -t reads the configuration of every site on the server, so ten customers saving at the same moment would mean ten full tests. Applies that wait for the same service are therefore collected: whoever gets the lock stages and swaps all waiting changes, runs one test and one reload, and gives each its own result. If that combined test fails, everything is rolled back and each change tests itself, so one broken change still cannot block the others; it costs at most one extra test.

One customer's mistake affects only that customer

A configuration test checks the whole service, so a single invalid file can make every apply on the server fail. That happens most often with a file that became invalid without being changed: a certificate that was removed, a directory that no longer exists, an IP address the server can no longer bind.

Berth handles that case explicitly. When a test fails, the agent rolls back and checks whether the configuration from before the change also fails. If it does, the problem is not the new change but a file that was already broken. The agent finds that file from the test output and sets it aside under a .berth-quarantine name that the includes do not read, keeping its content for inspection. Then it tests again and lets the original change through.

  • Only a file in the service's rendered directory can be quarantined, never a file that belongs to the change being applied.
  • If the test still fails after quarantining, everything goes back: Berth prefers touching nothing over touching too much.
  • A quarantined file raises an alert for the administrator, a warning in berth doctor and a notice to the customer whose domain it is. Until it is fixed, that one site or pool is left out of the configuration, while every other site keeps working and keeps accepting changes.
  • The quarantine is lifted automatically as soon as a valid version of that file is applied or the domain is removed.

DNS works the same way per zone: a zone that fails named-checkzone keeps serving its previous version.

The change log

Audit log → Changes lists every configuration the panel writes that actually changes something: which file, who caused it, when, and whether the service's test passed. Open a change to see the full diff and the steps (stage, swap, test, reload) with their duration and the exact command, including attempts that were rolled back. You can search by domain or any text in the diff.

berth admin changes --limit 50
berth admin changes --contains acme.nl

The broader activity log, with its tamper-evident hash chain, is described in Audit trail and approvals.

Customising safely

Several layers let you change what Berth renders without giving up validation:

  • Per-domain web server directives (Custom web server rules): extra nginx or Apache directives for one domain. Off by default per package; validated before activation; the agent binds paths, sockets and ports to the subscription's own webspace and refuses dangerous directives. See Web server settings.
  • Template fragments for hosters: files under /etc/berth/local/sjablonen/ that hook into named points of the nginx, Apache and PHP-FPM templates, optionally per package. berth sjablonen check validates them before use, and berth domain reprovision applies them.
  • Server policy: root-only TOML files in beleid.d under /etc/berth with hard limits that neither packages nor the panel can loosen. Unknown keys or invalid values make the agent refuse the whole file and keep the last valid policy, and berth doctor reports it. berth beleid show and berth beleid check; the panel shows the policy read-only at Server policy.

Repairing drift

If a server has been changed by hand, or a restore left something inconsistent, berth repair puts it back into the state the panel knows:

berth repair --dry-run              # show what would happen
berth repair --areas config         # rewrite every domain, mail and the panel from the database
berth repair                        # config, permissions, services and the SSH guard

berth doctor runs before and after. In the panel: System → Diagnosis, Fix… on a finding. See Services and diagnostics.

Why this matters

  • A typo, a missing certificate or a bad directive never takes the web server or mail down for everyone.
  • Every change is reversible and visible, with the exact diff.
  • Updates of Berth itself re-render every site through the same pipeline, so new protections apply everywhere without risk; see Updating Berth.