Repository navigation
Pick the reverse proxy per machine: Caddy, nginx, Apache or Traefik - #20
Merged
Merged
Conversation
…with HTTPS for each, and switching moves the machine's existing sites over
liamdevss
added a commit
to serveroshq/panel
that referenced
this pull request
Nov 16, 2026
Closes #92. Goes with serveroshq/daemon#20. When a deploy has a domain, the deploy dialog now has a **Reverse proxy** dropdown: Caddy, nginx, Apache or Traefik. It starts on whatever the machine uses. Picking another one shows that deploying moves every site on the machine over and stops the old proxy, since only one of them can have ports 80 and 443. **Panel** - `machines.proxy`: what serves the machine's domains, from the daemon's hello and from each finished deploy. - `/machines/{machine}/deploy/taken` also returns `proxy` and `canChooseProxy`, which is how the dialog learns both when it opens. - A deploy sends `proxy` only when it differs from the machine's current one and there's a domain. Machines that never reported a proxy count as Caddy. - Gated on `daemon.proxy_choice_since` (0.1.1-pre.40, the next daemon release). Older daemons don't get the dropdown, and asking for a proxy through the API or MCP is turned down with "too old to switch reverse proxy". - `deploy_from_git` and `deploy_template` (MCP) take `proxy` too. - Copy follows the proxy: the wildcard hint says subdomains are plain HTTP on nginx, Apache and Traefik, and the done step names the proxy that gets the certificate. Translations added for es, de and hi. - A proxy that won't start is explained by name, with the right `systemctl` command. **Checked** - New `ReverseProxyChoiceTest` (10 tests), and `ServiceTemplateTest` updated for the two new fields on the taken endpoint. - Full `tests/` suite: one failure, `SyncDaemonReleasesTest`, which also fails without this change in my local setup (local `.env` release URL). - Pint, PHPStan on the changed files, `vp check`, `vue-tsc`. - Not checked: the dropdown rendered in a browser. Co-authored-by: liamdevss <213730082+liamdevss@users.noreply.github.com>
liamdevss
added a commit
that referenced
this pull request
Nov 16, 2026
Follow-up to #20, found by testing a switch on a real systemd machine. When the new proxy started and then fell over a moment later (in the test: something else had port 443, so Traefik exited right after `systemctl enable --now` returned), the switch counted it as done. The old proxy was already stopped and was then disabled, so every site went offline. Now, after writing the sites, the switch waits 4 seconds and checks that the new proxy's unit is still active and that port 80 accepts a connection. If not, it fails with the unit's journal, removes the new site files, stops **and disables** the new proxy (so it doesn't fight for the ports on the next boot), and starts the old one again. **Checked on Ubuntu 24.04 with systemd (a privileged container):** - Every switch with two sites: Caddy → nginx → Apache → Traefik → Caddy → nginx. Each time the new proxy holds port 80, both sites answer and the old proxy is inactive and disabled. - With port 443 held by another program, nginx → Traefik is refused ("Traefik started but stopped again"). nginx is active and enabled again, both sites answer, and Traefik is failed and disabled. - `cargo fmt`, `cargo clippy --workspace --all-targets -D warnings`, and the daemon-deploy tests. Co-authored-by: liamdevss <213730082+liamdevss@users.noreply.github.com>
liamdevss
added a commit
that referenced
this pull request
Nov 16, 2026
…#23) Fixes serveroshq/panel#97. **The bug.** certbot's HTTP challenge files went in `/var/lib/serveros/acme`, inside the daemon's state folder, which is `0700` root. nginx and Apache workers run as `www-data`, so Let's Encrypt's request for the challenge file got a 403 and every certificate request failed. Sites stayed on plain HTTP, retrying every 15 minutes forever. (My container test in #20 never got this far: Let's Encrypt refuses `.test` names before it asks for the file.) **The fix** - The challenge folder is now `/var/lib/serveros-acme`, created `0755`. - At start-up (30 s in), the daemon rewrites any site file it would now write differently and reloads the proxy, putting the old files back if it won't take them. Machines on v0.1.1-pre.40 fix themselves after updating, and the next certificate retry succeeds. **HTTPS on or off, per site** - `DeploySpec.https` (optional): false serves the domains over plain HTTP on every proxy, with no certificate and no redirect. That's for a CDN or proxy in front that does HTTPS, or a site that shouldn't have it. - The choice is kept in the site file (`https=off` on the `# ServerOS site:` line), so rollbacks, clones and switching proxies keep it. A deploy that doesn't say keeps what the site had, and HTTPS for a new one. **Checked on Ubuntu 24.04 with systemd** - With `/var/lib/serveros` at `700`, the old layout gives a 403 for the challenge file (workers run as www-data). The new one serves it. - A site file written by pre.40 gets its challenge folder rewritten by `refresh_sites`, and the challenge is served afterwards. - A site with HTTPS off is served over HTTP with `https=off` in its file, and certbot isn't run for it. - `cargo fmt`, `cargo clippy --workspace --all-targets -D warnings` and the tests. New tests cover the folder location, HTTPS off on all four proxies (nothing on 443, no redirect, no resolver, no on-demand TLS), reading it back, and a certificate on disk not turning an HTTPS-off site back on. Co-authored-by: liamdevss <213730082+liamdevss@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For serveroshq/panel#92. A deploy can now say which reverse proxy should serve the machine's domains. If it isn't the one in use, the daemon moves every site ServerOS serves on the machine over to it first, and keeps the choice in
daemon.toml.What each proxy does
/etc/nginx/serveros.d, included from thehttpblock. HTTPS through certbot (webroot challenge in/var/lib/serveros/acme), with an HTTP to HTTPS redirect once the certificate is there and a renewal hook that reloads nginx. Fixes the old renderer, which used$connection_upgradewithout defining it, songinx -tfailed on a stock config./etc/apache2/serveros.dthroughIncludeOptional, the proxy modules switched on, HTTPS through certbot like nginx.CAP_NET_BIND_SERVICE. Sites are TOML files for its file provider and get certificates from aserverosACME resolver. A Traefik someone set up by hand is left alone: the deploy says what to add to its config.Wildcard subdomains stay plain HTTP on nginx, Apache and Traefik (the deploy says so): a certificate per subdomain needs Caddy's on-demand TLS. Behind a tunnel, every proxy serves plain HTTP.
Switching
Stops the current proxy (only one can have ports 80 and 443), installs the new one if needed, writes each site for it and starts it. If anything fails on the way, the new site files are removed and the old proxy is started again. Site files now carry a
# ServerOS site: port=… domains=…line so any proxy can read them back; Caddy and nginx files written before it still read back.Certificates that aren't ready yet
certbot doesn't keep retrying the way Caddy does. A site whose domain doesn't point here yet stays on plain HTTP, and a worker tries again every 15 minutes.
Wire changes (all optional, older panels and daemons ignore them)
DeploySpec.proxy: caddy, nginx, apache or traefik.Hello.proxy: the proxy in use.proxy.Checked
cargo fmt,cargo clippy --workspace --all-targets -D warnings,cargo test --workspace.nginx -t,apache2ctl configtest, then the challenge path, the redirect, HTTPS proxying, wildcard and tunnel sites), andtraefik:v3(redirect, wildcard and tunnel routing, no config errors).