Important Note:
Cloudflare Zero Trust has a 100-second timeout limit. If any cPFence WebUI operation takes too long (such as bulk actions across servers),
you may see a 524: A timeout occurred error. This is a Cloudflare limitation, not a cPFence issue.
Learn more here.
To avoid this, access the WebUI directly at: http://your-server-ip:9095
when performing long tasks.
Are you sick of whitelisting your IP each time you want to log in to the cPFence WebUI? Want to secure your WebUI with SSL? Great, this guide is for you.
This guide shows how to expose your cPFence WebUI over Cloudflare Tunnel and secure it using Cloudflare Access (Zero Trust) with a one-time login PIN and a single approved email address.
1. Install cloudflared
sudo mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg \
| sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared noble main' \
| sudo tee /etc/apt/sources.list.d/cloudflared.list
sudo apt-get update && sudo apt-get install cloudflared
2. Authenticate the tunnel connector
cloudflared tunnel login
In your browser, select your domain zone and click Authorize.
3. Create the tunnel
cloudflared tunnel create cpfence-webui
4. Route your subdomain
cloudflared tunnel route dns cpfence-webui your-subdomain.example.com
5. Write the tunnel config
sudo mkdir -p /etc/cloudflared
sudo tee /etc/cloudflared/config.yml >/dev/null <<EOF
tunnel: cpfence-webui
credentials-file: /root/.cloudflared/$(basename /root/.cloudflared/*.json)
ingress:
- hostname: your-subdomain.example.com
service: http://localhost:9095
- service: http_status:404
EOF
6. Install and start the service
sudo cloudflared service install
sudo systemctl enable --now cloudflared
7. Verify
dig +short your-subdomain.example.com
cloudflared tunnel info cpfence-webui
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:9095
8. To uninstall the tunnel and service, use:
cloudflared tunnel cleanup cpfence-webui
cloudflared tunnel delete cpfence-webui
sudo cloudflared service uninstall
9. Create an Access Policy
Create a single Allow policy with the following rules:
- Include: Country — choose your country from the list
- Require: Emails — enter your own email address (e.g. your.email@domain.com)
This ensures only users from your country and with the specified email can access the app.
Steps:
- Go to Zero Trust → Access → Policies → Create new policy
- Policy name:
allow-webui
- Action: Allow
- Session duration: Same as application session timeout
- Under Include, choose Country and enter your country
- Under Require, choose Emails and enter your email
- Click Save
When logging in, Cloudflare will send a one-time PIN to the approved email for access.
10. Publish the Access Application
Go to Zero Trust → Access → Applications → Add an application
Type: Self-hosted
Application name: cPFence WebUI
Session duration: 1 week (or leave as default)
Under Public hostname:
Scroll to Access policies and select the policy you just created (allow-webui
)
Click Save
You're done. Now your cPFence WebUI is protected with HTTPS, secured behind Cloudflare, and only accessible via your email with a one-time PIN.