← Back to Home
Case Study

Cloudflare Tunnel Setup with AI

How Claude Code automated a complex infrastructure task in under 2 minutes

The Challenge

Expose a local nginx container (running on port 86) to the internet via Cloudflare Tunnel at nginx.leebasehome.com — a task that typically requires reading documentation, navigating multiple API endpoints, managing secrets, and debugging Docker networking.

What Actually Happened

Human effort: Pasted an API token into a file when prompted.

Everything else was automated.

The Execution

1

API Discovery

Retrieved Cloudflare Account ID and Zone ID via API calls

2

Tunnel Creation

Created a new Cloudflare Tunnel with a cryptographically secure secret using OpenSSL

3

DNS Configuration

Created CNAME record pointing the subdomain to the tunnel endpoint

4

Local Configuration

Generated config.yml and credentials JSON with all values correctly populated

5

Container Deployment

Launched cloudflared Docker container with proper host networking

6

Verification

Confirmed 4 tunnel connections and tested the live endpoint

The Result

https://nginx.leebasehome.com

Live and serving traffic through Cloudflare's global network

Time Comparison

Traditional Approach

30-60 minutes
  1. Read Cloudflare tunnel documentation
  2. Install cloudflared CLI locally
  3. Run tunnel login (opens browser)
  4. Run tunnel create command
  5. Manually create config.yml
  6. Figure out Docker networking
  7. Debug permission issues
  8. Set up DNS in dashboard
  9. Test and troubleshoot

With Claude Code

~2 minutes
  1. Provide a plan document
  2. Paste API token when asked
  3. Done

Capabilities Demonstrated

API Integration

Called 5 different Cloudflare API endpoints seamlessly

Secret Management

Generated cryptographic secrets with OpenSSL

File Generation

Created properly formatted YAML and JSON configs

Docker Operations

Pulled image, configured networking, launched container

Adaptive Problem-Solving

Switched from jq to Python when jq wasn't installed

Verification

Checked logs, API status, and live endpoint

Why This Matters

Advantage Description
Context Retention Tracked IDs, secrets, and file paths across multiple steps without losing information
Tool Orchestration Combined curl, openssl, docker, and file operations into a coherent workflow
Error Adaptation When one tool wasn't available, immediately switched to alternatives
Domain Knowledge Knew API structures, Docker quirks, and config file formats
Built-in Verification Confirmed success at each step, not just blind execution

The Bottom Line

The human stayed in control — approving the plan, providing credentials — while the AI handled all the tedious execution details. This is the future of infrastructure management.