Cloudflare Tunnel
Firewall Rules & Zero Trust Access
Secure internal services without opening ports. WAF, DDoS protection, bot management & access policies combined.
Why Cloudflare Tunnel?
Cloudflare Tunnel (formerly Argo Tunnel) enables secure access to internal services without VPN and without opening firewall ports. Traffic is routed through Cloudflare's global network with integrated DDoS protection and WAF.
Traditional (Old)
- ✗VPN server publicly exposed
- ✗Open ports 443/80
- ✗DDoS vulnerability
- ✗Static IP whitelists
- ✗Complex VPN configuration
Cloudflare Tunnel (Modern)
- ✓No public ports needed
- ✓Outbound connection only (HTTPS)
- ✓Integrated DDoS protection
- ✓Identity-based access
- ✓Global edge performance
Cloudflare Tunnel Architektur
SSO Auth
WAF + DDoS + Access
No public IP
cloudflared Installation
Docker Compose
services:
cloudflared:
image: cloudflare/cloudflared:latest
command: tunnel --no-autoupdate run
environment:
- TUNNEL_TOKEN=$TUNNEL_TOKEN
restart: unless-stopped
# Your internal service
web:
image: nginx:alpine
networks:
- internalKubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: cloudflared
spec:
replicas: 2
selector:
matchLabels:
app: cloudflared
template:
spec:
containers:
- name: cloudflared
image: cloudflare/cloudflared:latest
args:
- tunnel
- --no-autoupdate
- run
- --token
- $(TUNNEL_TOKEN)
env:
- name: TUNNEL_TOKEN
valueFrom:
secretKeyRef:
name: tunnel-token
key: tokenToken Management
Store the tunnel token securely in Kubernetes Secrets, Docker Secrets, or Vault. Never commit to Git!
Cloudflare Access Policies
Cloudflare Access Policies define who gets access to your tunnels. Integrated with OIDC, SAML, OTP, and Service Tokens.
Access Policy Configuration
# cloudflare-access.yaml
name: "Internal Dashboard"
include:
# Require SSO authentication
- idp:
name: "Company Okta"
# OR require Service Token (for APIs)
- service_token:
name: "api-service-token"
# AND require specific email domains
- email:
domain: "company.com"
# AND require country
- geo:
country: ["DE", "AT", "CH"]
exclude:
# Block specific users
- email:
email: "ex-employee@company.com"
require:
# Require MFA
- authentication_method:
methods: ["mfa"]IdP Integration
- • Okta / Azure AD / Google
- • OneLogin / Ping Identity
- • GitHub / GitLab OAuth
- • Generic OIDC / SAML 2.0
Service Tokens
- • API-to-API Authentication
- • CI/CD Pipeline Access
- • Service Mesh Integration
- • mTLS Alternative
WAF & Security Integration
Security Layers
Layer 3/4/7 DDoS mitigation automatisch
AI-gestützte Bot-Erkennung
OWASP Top 10, SQLi, XSS Protection
Identity-based access control
Custom WAF Rule for Tunnel
resource "cloudflare_ruleset" "tunnel_waf" {
zone_id = var.zone_id
name = "Tunnel Security Rules"
kind = "zone"
phase = "http_request_firewall_custom"
# Block known bad bots
rules {
action = "block"
expression = "(cf.bot_management.score lt 10)"
description = "Block low-reputation bots"
}
# Rate limiting per IP
rules {
action = "block"
expression = "(http.request.uri.path contains "/api/" and cf.threat_score gt 50)"
description = "Block high-risk IPs on API"
}
# Geo-blocking if needed
rules {
action = "block"
expression = "(not ip.geoip.country in {"DE" "AT" "CH"})"
description = "Block non-DACH countries"
}
}Best Practices 2026
High Availability
- ✓Minimum 2 cloudflared replicas
- ✓Multi-region deployment
- ✓Configure health checks
- ✓Automatic failover
Security
- ✓SSO for all internal services
- ✓Service tokens for APIs
- ✓Enable audit logging
- ✓Configure session timeouts
Ready for Zero Trust?
Migrate your internal services to Cloudflare Tunnel. No public ports needed anymore.
Migration Assessment