cloudflare-tunnel
Skill1 starsChanged 5 months agoMITView on GitHub
Use this skill for Cloudflare Tunnel (cloudflared) — zero-trust public exposure without open ports, K3s/Kubernetes HA deployment, ConfigMap-based config management, DNS automation, adding/removing service routes, and Traefik IngressRoute integration. Activate for any cloudflared setup, tunnel routing, or *.yourdomain.com exposure work.
- Reads credentials
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- pedram19941/cloudflare-tunneltheir own version, first seen Jul 25, 2026
- okou-ai/okou-skillstheir own version, first seen Mar 26, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- okou-ai/okou-skills★ 77same name
- pedram19941/cloudflare-tunnel★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- cad-designSkill
- context-engineeringSkill
- create-branchSkill
- create-releaseSkill
- digital-fabricationSkill
- docker-swarmSkill
- grafana-prometheusSkill
- k3s-kubernetesSkill
- linux-server-adminSkill
- merge-prSkill
- mikrotik-routerosSkill
- network-engineerSkill
- nextjs-deploymentSkill
- open-projectSkill
- open-prSkill
- proxmox-homelabSkill
- pr-reviewSkill
- python-fastapiSkill
- thai-dev-workflowSkill
- wireguard-vpnSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
No open firewall ports. No public IP needed.
- Distinctive: line 213
Use Cloudflare Zero Trust Access policies to add auth (SSO, email OTP) in front of any tunnel service.
- Distinctive: line 214
No inbound firewall rules needed — all traffic is outbound from your server to Cloudflare.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cloudflare Tunnel
Core Concept
Cloudflare Tunnel (cloudflared) creates an outbound-only connection from your server to Cloudflare's edge — no inbound ports needed. Traffic flows:
User → Cloudflare Edge → cloudflared daemon → your serviceNo open firewall ports. No public IP needed. Wildcard domains covered by Cloudflare Universal SSL (single-label only: *.example.com ✓, *.sub.example.com ✗).
Initial Setup
# Install cloudflared
curl -L https://pkg.cloudflare.com/cloudflare-main.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-main.gpg
echo "deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main" | sudo tee /etc/apt/sources.list.d/cloudflared.list
sudo apt update && sudo apt install cloudflared
# Authenticate (browser login)
cloudflared tunnel login
# Create tunnel
cloudflared tunnel create my-tunnel
# Saves credentials to ~/.cloudflared/<TUNNEL_ID>.json
# Create DNS CNAME pointing to tunnel
cloudflared tunnel route dns my-tunnel service.example.comConfig File Structure
# ~/.cloudflared/config.yml (or ConfigMap in K3s)
tunnel: TUNNEL_ID
credentials-file: /home/nonroot/.cloudflared/TUNNEL_ID.json
ingress:
- hostname: app1.example.com
service: http://localhost:3000
- hostname: app2.example.com
service: http://localhost:8080
- hostname: ssh.example.com
service: ssh://localhost:22
- service: http_status:404 # catch-all — required at endK3s Kubernetes HA Deployment
ConfigMap-based config (preferred over hostPath):
# cloudflared-config ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: cloudflared-config
namespace: apps
data:
config.yml: |
tunnel: TUNNEL_ID
credentials-file: /etc/cloudflared/creds/credentials.json
ingress:
- hostname: app.example.com
service: http://app-service.apps.svc.cluster.local:3000
- service: http_status:404
---
# Credentials Secret
apiVersion: v1
kind: Secret
metadata:
name: cloudflared-credentials
namespace: apps
type: Opaque
stringData:
credentials.json: |
{"AccountTag":"...","TunnelSecret":"...","TunnelID":"TUNNEL_ID"}
---
# Deployment — 2 replicas for HA
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflared
namespace: apps
spec:
replicas: 2
selector:
matchLabels:
app: cloudflared
template:
metadata:
labels:
app: cloudflared
spec:
containers:
- name: cloudflared
image: cloudflare/cloudflared:latest
args: ["tunnel", "--config", "/etc/cloudflared/config/config.yml", "run"]
volumeMounts:
- name: config
mountPath: /etc/cloudflared/config
- name: creds
mountPath: /etc/cloudflared/creds
volumes:
- name: config
configMap:
name: cloudflared-config
- name: creds
secret:
secretName: cloudflared-credentials
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: cloudflaredAdd a new service route (K3s pattern):
# 1. Register DNS
cloudflared tunnel route dns TUNNEL_ID newservice.example.com
# 2. Edit ConfigMap
kubectl edit cm cloudflared-config -n apps
# Add under ingress (before catch-all):
# - hostname: newservice.example.com
# service: http://newservice-svc.apps.svc.cluster.local:PORT
# 3. Rollout
kubectl rollout restart deployment/cloudflared -n apps
kubectl rollout status deployment/cloudflared -n appsCreate K3s IngressRoute for the new service:
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: newservice
namespace: apps
spec:
entryPoints: [web]
routes:
- match: Host(`newservice.example.com`)
kind: Rule
services:
- name: newservice-svc
port: PORTRemove a Service
# 1. Remove from ConfigMap ingress
kubectl edit cm cloudflared-config -n apps
# 2. Rollout
kubectl rollout restart deployment/cloudflared -n apps
# 3. Remove DNS record (via Cloudflare API or dashboard)
# cloudflared does not auto-delete DNS on removalDNS Automation
# Add DNS CNAME via cloudflared CLI
cloudflared tunnel route dns TUNNEL_ID subdomain.example.com
# Via Docker (no local cloudflared install)
docker run --rm \
-v ~/.cloudflared:/home/nonroot/.cloudflared:ro \
cloudflare/cloudflared tunnel route dns TUNNEL_ID subdomain.example.comMetrics & Health
# cloudflared metrics endpoint (port 2000 by default)
curl http://localhost:2000/metrics
# Check tunnel status
cloudflared tunnel info TUNNEL_ID
cloudflared tunnel list
# K3s — check pod status
kubectl get pods -n apps -l app=cloudflared
kubectl logs -n apps deploy/cloudflared --tail=50Troubleshooting
| Symptom | Cause | Fix |
502 Bad Gateway | Service not running on target port | Check upstream service health |
1033 - Tunnel not found | Wrong tunnel ID in credentials | Re-run cloudflared tunnel login + recreate |
| DNS not resolving | CNAME not propagated | Check cloudflared tunnel route dns output; allow 5 min TTL |
| Pod crash loop | Wrong credentials path | Verify Secret mount path matches credentials-file in config |
| Config changes not applied | Deployment not restarted | kubectl rollout restart deployment/cloudflared -n apps |
Security Notes
- Tunnel credentials JSON contains the tunnel secret — store as Kubernetes Secret, never in ConfigMap.
- Wildcard
*.example.comcovers only single-label subdomains; multi-level likea.b.example.comrequires explicit DNS entry. - Use Cloudflare Zero Trust Access policies to add auth (SSO, email OTP) in front of any tunnel service.
- No inbound firewall rules needed — all traffic is outbound from your server to Cloudflare.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

