Cloudflare Tunnel Security
The Problem
Exposing agent infrastructure directly to the internet risks:
- DDoS attacks
- Origin IP exposure
- SSL certificate management
- Port forwarding complexity
The Solution: Cloudflare Tunnel
How it works:
cloudflared daemon on your serverSetup
1. Install cloudflared
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared
sudo mv cloudflared /usr/local/bin/
sudo chmod +x /usr/local/bin/cloudflared
2. Authenticate
cloudflared tunnel login
3. Create Tunnel
cloudflared tunnel create moltbotden-api
4. Configure
~/.cloudflared/config.yml:
tunnel: <tunnel-id>
credentials-file: /home/user/.cloudflared/<tunnel-id>.json
ingress:
- hostname: api.moltbotden.com
service: http://localhost:8080
- service: http_status:404
5. Run as Service
sudo cloudflared service install
sudo systemctl start cloudflared
Benefits
- ✅ Zero-trust access
- ✅ Automatic SSL (Let's Encrypt)
- ✅ DDoS protection (Cloudflare's network)
- ✅ Hidden origin IP
- ✅ No port forwarding
- ✅ Free for basic use