# VMID 2400 Cloudflare Tunnel - Next Steps

**Status**: ✅ Cloudflared Installed and Running  
**Tunnel ID**: `26138c21-db00-4a02-95db-ec75c07bda5b`  
**Date**: 2026-01-02

---

## ✅ Completed

- ✅ Cloudflared installed on VMID 2400
- ✅ Tunnel service running and connected
- ✅ Tunnel ID: `26138c21-db00-4a02-95db-ec75c07bda5b`

---

## 📋 Next Steps

### Step 1: Configure Tunnel Route in Cloudflare Dashboard

1. **Go to Cloudflare Dashboard**:
   - URL: https://one.dash.cloudflare.com/
   - Login to your Cloudflare account

2. **Navigate to Tunnels**:
   - Click: **Zero Trust** (left sidebar)
   - Click: **Networks** → **Tunnels**

3. **Select Your Tunnel**:
   - Find tunnel: `26138c21-db00-4a02-95db-ec75c07bda5b`
   - Click on the tunnel name

4. **Configure Public Hostname**:
   - Click: **Configure** button
   - Go to: **Public Hostname** tab
   - Click: **Add a public hostname**

5. **Configure Route**:
   ```
   Subdomain: rpc.public-0138
   Domain: defi-oracle.io
   Service Type: HTTP
   URL: http://127.0.0.1:8545
   ```
   - Click: **Save hostname**

---

### Step 2: Configure DNS Record

1. **Navigate to DNS**:
   - In Cloudflare Dashboard, go to your account overview
   - Select domain: **defi-oracle.io**
   - Click: **DNS** (left sidebar)
   - Click: **Records**

2. **Add CNAME Record**:
   - Click: **Add record**

3. **Configure Record**:
   ```
   Type: CNAME
   Name: rpc.public-0138
   Target: 26138c21-db00-4a02-95db-ec75c07bda5b.cfargotunnel.com
   Proxy: 🟠 Proxied (orange cloud) - IMPORTANT!
   TTL: Auto
   ```

4. **Save**:
   - Click: **Save**
   - Wait 1-2 minutes for DNS propagation

---

### Step 3: Verify Setup

#### 3.1 Check Tunnel Status in Dashboard

1. Go to: **Zero Trust** → **Networks** → **Tunnels**
2. Click on your tunnel
3. Status should show: **Healthy** (green)
4. You should see the hostname `rpc.public-0138.defi-oracle.io` listed

#### 3.2 Test DNS Resolution

```bash
# Test DNS resolution (full FQDN)
dig rpc.public-0138.defi-oracle.io
nslookup rpc.public-0138.defi-oracle.io

# Test DNS resolution (short alias)
dig rpc.defi-oracle.io
nslookup rpc.defi-oracle.io

# Should resolve to Cloudflare IPs (if proxied)
```

#### 3.3 Test RPC Endpoint

```bash
# Test HTTP RPC endpoint (full FQDN)
curl -k https://rpc.public-0138.defi-oracle.io \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

# Test HTTP RPC endpoint (short alias)
curl -k https://rpc.defi-oracle.io \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

# Expected: JSON response with block number (both should work identically)
```

#### 3.4 Verify Besu RPC is Running

```bash
# Check Besu RPC service on VMID 2400
ssh root@192.168.11.10 "pct exec 2400 -- systemctl status besu-rpc"

# Test Besu RPC locally (inside container)
ssh root@192.168.11.10 "pct exec 2400 -- curl -X POST http://127.0.0.1:8545 \
  -H 'Content-Type: application/json' \
  -d '{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}'"
```

---

## 📝 Quick Reference

**Tunnel ID**: `26138c21-db00-4a02-95db-ec75c07bda5b`  
**CNAME Target**: `26138c21-db00-4a02-95db-ec75c07bda5b.cfargotunnel.com`  
**FQDN**: `rpc.public-0138.defi-oracle.io`  
**Short Alias**: `rpc.defi-oracle.io`  
**DNS Structure**: `rpc` → `rpc.public-0138` → `tunnel endpoint`  
**Service URL**: `http://127.0.0.1:8545` (Besu RPC)  
**VMID**: 2400  
**IP**: 192.168.11.240

---

## 🔍 Troubleshooting

### Tunnel Not Showing in Dashboard

- Wait a few minutes for Cloudflare to sync
- Refresh the browser
- Check tunnel ID matches: `26138c21-db00-4a02-95db-ec75c07bda5b`

### DNS Not Resolving

- Verify CNAME target is correct: `26138c21-db00-4a02-95db-ec75c07bda5b.cfargotunnel.com`
- Ensure Proxy is enabled (🟠 orange cloud)
- Wait 1-2 minutes for DNS propagation

### Connection Refused

- Verify Besu RPC is running: `systemctl status besu-rpc`
- Test locally: `curl http://127.0.0.1:8545` (inside container)
- Check tunnel route URL is correct: `http://127.0.0.1:8545`

### Check Tunnel Logs

```bash
# View recent logs
ssh root@192.168.11.10 "pct exec 2400 -- journalctl -u cloudflared -n 50 --no-pager"

# Follow logs in real-time
ssh root@192.168.11.10 "pct exec 2400 -- journalctl -u cloudflared -f"
```

---

**Last Updated**: 2026-01-02  
**Status**: ✅ Ready for DNS and Route Configuration
