A patch and build script that make Cloudflare's cloudflared
compile and run on OpenBSD.
Upstream cloudflared ships a diagnostic system collector for Linux, macOS, and
FreeBSD, but not OpenBSD, so recent releases fail to build for openbsd/amd64.
This repository supplies the missing collector and a script that cross-builds a
static binary from an unmodified upstream tree.
The tunnel data path is upstream code, untouched. The added collector runs only
under cloudflared tunnel diag.
- Go (a recent toolchain; the build uses
GOTOOLCHAIN=auto) git- Any OS that can cross-compile for OpenBSD (the build host does not need to be OpenBSD)
sh build.sh # builds against cloudflared 2026.6.0 (default)
sh build.sh 2026.5.0 # or pin a specific upstream versionbuild.sh clones cloudflared at the requested tag, applies the two changes
described below, and builds with CGO_ENABLED=0. The result is a static binary
named cloudflared-openbsd-amd64.
On the OpenBSD host:
doas install -o root -g bin -m 755 cloudflared-openbsd-amd64 /usr/local/sbin/cloudflared
cloudflared --versionThe build produces a binary only. To run it as a managed daemon on OpenBSD:
-
Create an unprivileged user:
doas useradd -d /var/empty -s /sbin/nologin -c "Cloudflare Tunnel" -L daemon _cloudflared -
Configure the tunnel. cloudflared reads
/etc/cloudflared/config.yml; point it at your tunnel and its credentials file (see Cloudflare's docs). Keep the token or credentials in that file, not in the rc script, and make it readable only by_cloudflared. -
Install the rc.d script from
contrib/cloudflared.rc:doas install -o root -g bin -m 555 contrib/cloudflared.rc /etc/rc.d/cloudflared doas rcctl enable cloudflared doas rcctl start cloudflared
For a named tunnel, override the flags in /etc/rc.conf.local, for example:
rcctl set cloudflared flags "--no-autoupdate tunnel run mytunnel"Two files, both confined to the diagnostic collector:
system_collector_openbsd.go(added) implementsSystemCollectorImplfor OpenBSD. It reads memory and file-descriptor counts throughsysctl:hw.physmemfor total memory,kern.maxfilesandkern.nfilesfor descriptors. Adapted from the FreeBSD ports patch.diagnostic/network/collector_unix.go(modified at build time) has its//go:buildconstraint rewritten to includeopenbsd, so the shared Unix network collector compiles for the platform.build.shperforms this rewrite; the upstream file is not edited in this repository.
- Current (used) memory is reported as
0. OpenBSD exposes no single sysctl scalar for free memory, so the collector reports total memory only. This affects thetunnel diagoutput, nothing else. - Only
openbsd/amd64is built. Other architectures are untested.
This is a bridge until OpenBSD support lands in cloudflared itself. The same
patch is carried by the ports-tree port;
the durable home for OpenBSD support is upstream cloudflared or the ports tree,
not a standalone build script. If you can, help move it there.
- Reporting a vulnerability:
SECURITY.md - Submitting changes:
CONTRIBUTING.md - Community expectations:
CODE_OF_CONDUCT.md - Version history:
CHANGELOG.md
Apache-2.0, matching cloudflared. See LICENSE.
This is not an official Cloudflare project and is not affiliated with or endorsed by Cloudflare, Inc. "Cloudflare" and "cloudflared" are trademarks of Cloudflare, Inc., used here only to identify the upstream software.