OpenBSD httpd Static-Site Deploy (preview)
A dependency-light native OpenBSD /bin/ksh script for managing small static websites using the stock httpd(8) and acme-client(1).
Features
- Dry-run by default; add
--applyto write anything. - Validates a lowercase DNS domain and checks that the source contains
index.html, no symlinks, special files or obvious private/server-side files. - Manages only explicitly marked blocks of
/etc/httpd.confand/etc/acme-client.conf, refusing a directly conflicting unmanaged block. - Copies a static directory to
/var/www/htdocs/<domain>with per-operation site/configuration backups. - Uses
httpd -n -f /etc/httpd.confbefore reloading the service. - Configures ACME HTTP-01 and enables HTTPS after a certificate is available.
- Preserves HTTPS settings when re-deploying a previously TLS-enabled site.
- Lists backups and provides explicit rollback with
cksumintegrity checks. - Attempts automatic restoration after validation/reload failures.
Prerequisites
OpenBSD with stock httpd, acme-client, rcctl, awk, tar, find, cksum, and /bin/ksh. DNS A/AAAA records should already resolve to the server. Firewall must allow inbound TCP 80 for HTTP-01 and 443 for HTTPS; that configuration is not modified by the tool. The site must be static HTML/CSS/JS/assets. Dynamic PHP/FastCGI applications are not supported.
Prepare /etc/httpd.conf with your usual non-conflicting global and other site declarations. Ensure httpd is enabled and running (e.g., doas rcctl enable httpd followed by doas rcctl start httpd after verifying the base config). The deployer does not change daemon enablement.
For ACME, create or maintain a valid /etc/acme-client.conf including a usable authority named letsencrypt. Use /etc/examples/acme-client.conf as a starting reference, tailoring the authority's URL and account-key location. The tool will append only its managed domain block. Ensure /var/www/acme exists and the ACME HTTP-01 path can be reached from the internet. The tool does not configure DNS, enable recurring renewals or handle wildcard certificates.
Install
install -m 755 obsd-webdeploy.ksh /usr/local/sbin/obsd-webdeploy
Typical workflow
# Print generated HTTP/HTTPS configuration without altering the server
obsd-webdeploy render --domain example.org
obsd-webdeploy render --domain example.org --tls
# Show the intended operation without changing files
obsd-webdeploy deploy --domain example.org --source /home/admin/site
# Deploy site and HTTP configuration
doas obsd-webdeploy deploy --domain example.org --source /home/admin/site --apply
# Inspect ACME/TLS changes first, then request a certificate
obsd-webdeploy enable-tls --domain example.org
doas obsd-webdeploy enable-tls --domain example.org --apply
# View saved restore points
obsd-webdeploy list --domain example.org
# Preview a restore, then apply it
obsd-webdeploy rollback --domain example.org --backup 20261103T101530-1234
doas obsd-webdeploy rollback --domain example.org --backup 20261103T101530-1234 --apply
Each website is deployed under /var/www/htdocs/<domain>, visible to the httpd chroot as /htdocs/<domain>. Restore points are saved at /var/backups/obsd-webdeploy/<domain>/<timestamp>-<pid>. Backups contain the live site's previous contents and copies of both configuration files; do not publish backups.
ACME renewal
enable-tls requests an initial certificate and enables port 443 after that succeeds. It does not install a scheduled renewal job. After confirming your ACME configuration works, schedule acme-client according to the OpenBSD manual; the client returns 0 for renewed and 2 for unchanged, so automation must treat both as expected. Reload httpd after certificates change. Preserve any site-specific account/authority settings.
Limitations and operational risks
httpd.confis a shared server-wide resource. The script only owns blocks it marks, but other global listeners, aliases and unrelated manual blocks can still conflict. Inspect rendered configuration and use a disposable VM for first deployment.- The tool is conservative about untrusted sources but is not a multi-tenant isolation service. It does not implement filesystem privilege separation, locking for concurrent deployments, staging with atomic swaps across all failure cases, or symlink preservation.
- The source may not contain
.git,.env,.htpasswd,*.key,*.pem,*.phpor*.sqlite; review all content for secrets independently. - Restores copy website files plus HTTPD/ACME config only. They do not roll back issued/revoked certificates, ACME account keys, pf rules, DNS records, cron, or external service state.
- Existing
httpdconfig validation requires an actual OpenBSD machine. ACME HTTP-01 requires a reachable port-80 vhost; TLS is not switched on until a certificate is present. - Multiple site changes should be serialized by the operator; do not run two deployments concurrently.
- Run with root only when applying changes. The default preview can be used without privilege if source and existing configs are readable.
References
- OpenBSD
httpd.conf(5): https://man.openbsd.org/httpd.conf - OpenBSD
httpd(8): https://man.openbsd.org/httpd - OpenBSD
acme-client.conf(5): https://man.openbsd.org/acme-client.conf - OpenBSD
acme-client(1): https://man.openbsd.org/acme-client
No open-source license is asserted in this preview until the copyright owner selects one.