Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Docs
  2. Security
  3. Cloudflare Zero Trust

Cloudflare Zero Trust

Reach SSH through Cloudflare and close port 22.

Security

Put your server behind Cloudflare: visitors reach apps through a Cloudflare Tunnel (with CDN and WAF), staging sites, the panel and SSH sit behind Cloudflare Access, and finally the origin closes its ports. Every step that could lock you out is a separate, explicit command. Off until you enable it.

Step 1 of 5Token

Create a Cloudflare API token with Tunnel, Access and DNS permissions and save it with cipi zt token set.

bash
cipi zt token set --token=CF_API_TOKEN --account=ACCOUNT_ID
cipi zt enable
cipi zt hostname add myapp           # public, through CDN/WAF
cipi zt access enable staging        # login required (Cloudflare Access)
cipi zt access enable --gui
cipi zt ssh enable --hostname=ssh.example.com
cipi zt lock http --yes              # 80/443 closed or Cloudflare-only
cipi zt lock ssh --yes               # port 22 closed
cipi zt status

Token permissions: Account · Cloudflare Tunnel: Edit, Account · Access: Apps and Policies: Edit, Zone · DNS: Edit (plus Zone · SSL and Certificates for Origin CA). It is stored root-only, separate from the DNS token used for certificates.

What each step does#

CommandEffectReversible with
enableInstalls cloudflared, a locally-managed tunnel, Nginx real-IP from Cloudflare's ranges (refreshed daily); Fail2ban/CrowdSec learn the ranges. No port is closeddisable
hostname add <app|--gui>DNS CNAME to the tunnel, ingress to Nginxhostname remove
access enable <app|--gui>Cloudflare Access login in front; /cipi/webhook bypassed so pushes still deployaccess disable
ssh enableSSH through the tunnel + Access; prints your ~/.ssh/configssh disable
lock http80/443 closed when everything is on the tunnel, else allowed from Cloudflare onlyunlock http
lock sshPort 22 closed (only if the tunnel already carries SSH)ssh unlock
text
# ~/.ssh/config on your laptop
Host ssh.example.com
  ProxyCommand cloudflared access ssh --hostname %h
  User cipi
  IdentityFile ~/.ssh/id_ed25519

Lock SSH only after ssh ssh.example.com works through the tunnel from your machine, and keep your provider's web console at hand. Deploys are unaffected (they use localhost).

Certificates#

lock http refuses while an app still renews over HTTP (Let's Encrypt can't reach a closed origin). Move apps first to cipi ssl install <app> --dns=cloudflare, or use a 15-year Cloudflare Origin CA certificate:

bash
cipi zt origin-cert myapp

Apps on the tunnel skip Cipi's HTTP→HTTPS redirect automatically (the tunnel talks HTTP to the origin and Cloudflare handles HTTPS). cipi zt disable reopens 22/80/443 and removes everything Cipi created in your Cloudflare account; Let's Encrypt certificates are left alone.