Skip to content

Fix certificates on nginx and Apache, and let a deploy turn HTTPS off - #23

Merged
liamdevss merged 1 commit into
mainfrom
https-choice
Nov 16, 2026
Merged

liamdevss merged 1 commit into
mainfrom
https-choice

Conversation

@liamdevss

Copy link
Copy Markdown
Contributor

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.

…ut of the root-only state folder, sites written before are rewritten at start-up, and a deploy can turn HTTPS off for a site
@liamdevss
liamdevss requested a review from a team as a code owner November 16, 2026 21:56
@liamdevss
liamdevss merged commit 2d667e9 into main Nov 16, 2026
12 checks passed
@liamdevss
liamdevss deleted the https-choice branch November 16, 2026 22:04
liamdevss added a commit to serveroshq/panel that referenced this pull request Nov 16, 2026
For #97, with serveroshq/daemon#23 (which fixes the actual bug: nginx
and Apache couldn't read certbot's challenge folder, so they never got a
certificate).

The deploy dialog gets a **Serve over HTTPS** tickbox under the domain,
on by default. With it on, the hint says the chosen proxy gets a
certificate and sends HTTP to HTTPS. With it off, it says the site is
plain HTTP with no certificate, for a CDN or proxy in front that does
HTTPS.

- A deploy with a domain sends `https` when the dialog (or the API or
MCP) says. Leaving it out lets the daemon keep what the app had, which
is HTTPS for a new one.
- Gated on `daemon.https_choice_since` (0.1.1-pre.41). The dialog only
shows the tickbox from that version. Turning HTTPS off on an older
daemon is refused with "too old to serve a domain without HTTPS", and
asking for HTTPS is always fine.
- The deploy result's address is `http://` when HTTPS is off, so the
done step doesn't promise a certificate.
- `deploy_from_git` and `deploy_template` (MCP) take `https` too.
- The wildcard hint only promises per-subdomain certificates for Caddy
with HTTPS on.
- Strings in es, de and hi.

**Checked**
- New `HttpsChoiceTest` (5 tests), and `ServiceTemplateTest` updated for
the new field.
- Full `tests/` suite: three failures that also fail without this change
in my local setup (AuditCoverage, SyncDaemonReleases, and a
trial-celebration test that passes on its own).
- Pint, PHPStan on the changed files, `vp check`, `vue-tsc`.

Co-authored-by: liamdevss <213730082+liamdevss@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deploying an app with NGINX doesn't setup SSL

1 participant