WIUNIX ACADEMY
Set up Cloudflare Tunnel and Access for a private Linux web app
Page 2 of 5. Review the earlier steps and prerequisites before continuing.
YOUR SYSTEM. YOUR STEPS.
Where are you working?
Choose your OS and version. The prerequisites, commands and troubleshooting follow your environment.
USE YOUR OWN VALUES
Configure this tutorial
Set the example values for your environment; related explanations and copy panels update together. Never enter passwords, private keys or tokens. Values stay in this tab and are not sent to the server or share links. Check actual DNS, certificates and network policy before running commands.
Different IP addresses, domains or ports? Open the settings below, change the values and select “Apply to tutorial”, then copy the updated commands.
Set values for my environment8 editable values
LET’S BUILD
Install prerequisites from distribution repositories
Install prerequisites from matching official RHEL/Rocky/Alma repositories on the fresh lab host. bind-utils, iproute and shadow-utils are actual RPM package names; use a supported minor release and authorized repositories.
Existing curl-minimal providing curl is sufficient for these HTTPS downloads. Install curl only when absent; do not automatically remove conflicting packages. Python serves the marker only.
Run at the location stated in this step
sudo dnf install ca-certificates gnupg2 python3 bind-utils iproute shadow-utils sudo policycoreutils audit
if ! command -v curl >/dev/null 2>&1; then sudo dnf install curl; fi
Distribution prerequisites are ready without removing the existing curl provider or bypassing verification.
LET’S BUILD
Inspect and add Cloudflare’s official RPM repository
Fetch cloudflared.repo only from the official URL and inspect it first: stable HTTPS repository, gpgcheck=1 and official signing key must remain enabled. Refuse an existing organization-managed file. Do not weaken signature/crypto checks to bypass failures.
This is the generic RPM repository, not an APT alias. The binary is /usr/bin/cloudflared; create this guide’s dedicated unit rather than using the token-bearing service-install command. Check the version and token-file help.
Run at the location stated in this step
sudo test ! -e /etc/yum.repos.d/cloudflared.repo || exit 1
repo_tmp=$(mktemp)
curl -fsSL https://pkg.cloudflare.com/cloudflared.repo -o "$repo_tmp" || exit 1
cat "$repo_tmp"
sudo install -m 0644 "$repo_tmp" /etc/yum.repos.d/cloudflared.repo
sudo dnf --refresh info cloudflared
sudo dnf install cloudflared
rpm -q cloudflared
rpm -V cloudflared
cloudflared --version
cloudflared tunnel run --help
The signature-verified vendor package is installed, file checks show no unexplained mismatch, and help includes token-file.
LET’S BUILD
Approve only the required outbound path
Use the current official firewall destination list: outbound UDP/7844 for QUIC and TCP/7844 for HTTP/2, plus DNS to your approved resolver. Repository downloads require HTTPS; connector-side Access JWT validation also needs HTTPS to your team cloudflareaccess.com endpoint. Do not assume TCP/443 replaces 7844. Keep existing inbound management policy unchanged, add no inbound origin port, and do not flush your firewall. The auto protocol can fall back to HTTP/2 when UDP is blocked. A successful TCP probe is not a QUIC handshake or an authorization test.
Run at the location stated in this step
getent ahostsv4 region1.v2.argotunnel.com
getent ahostsv4 region2.v2.argotunnel.com
dig SRV _v2-origintunneld._tcp.argotunnel.com
Resolvers return tunnel destinations. Network owner has approved required egress; actual connector transport is checked after startup.
LET’S BUILD
Create a dedicated harmless origin
Use a fresh dedicated directory containing only a nonsecret marker, never application data, a home directory, repository, credential store or backup. The fixed loopback address is intentional.
Create a dedicated academy-origin account/group instead of assuming a distribution-wide www-data account exists. Refuse an existing same-name account/group, path or unit. The origin can read its public marker; the separate connector credential remains root-only.
Run at the location stated in this step
sudo bash -eu <<'ORIGIN' &&
test ! -e '/srv/academy-origin'
test ! -e /etc/systemd/system/academy-origin.service
if getent passwd academy-origin >/dev/null || getent group academy-origin >/dev/null; then echo 'Existing origin account/group: STOP' >&2; exit 1; fi
useradd --system --user-group --no-create-home --shell "$(command -v nologin)" academy-origin
install -d -m 0755 '/srv/academy-origin'
install -d -m 0755 "$(dirname '/srv/academy-origin/health.txt')"
printf '%s\n' 'academy-tunnel-origin-ok' > '/srv/academy-origin/health.txt'
chmod 0644 '/srv/academy-origin/health.txt'
ORIGIN
sudoedit /etc/systemd/system/academy-origin.service
The fresh marker/account exist; the editor is open for the following dedicated unit.
Origin service file
FILE CONTENT: save this dedicated unit, not a shell command. It listens only on 127.0.0.1:8080 as the dedicated unprivileged academy-origin account.
[Unit]
Description=Academy loopback marker origin
After=network.target
[Service]
Type=simple
User=academy-origin
Group=academy-origin
ExecStart=/usr/bin/python3 -m http.server 8080 --bind 127.0.0.1 --directory /srv/academy-origin
Restart=on-failure
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
[Install]
WantedBy=multi-user.target
LET’S BUILD
Start and verify the loopback receiver
On the connector host, validate the unit before starting it. Verify the exact body, not just HTTP status. Inspect the listener address: no wildcard IPv4 or IPv6 binding. From a different machine, the host’s LAN/public address at this port must be unreachable; retain existing firewall policy. If that check fails, stop here and close the exposure before creating a route.
Run at the location stated in this step
sudo systemd-analyze verify /etc/systemd/system/academy-origin.service
sudo systemctl daemon-reload
sudo systemctl enable --now academy-origin.service
curl --fail --silent --show-error --noproxy '*' http://127.0.0.1:8080/health.txt
sudo ss -lntp 'sport = :8080'
Body is academy-tunnel-origin-ok and the listener is only 127.0.0.1:8080.