# Cloudflare Tunnel Installation - Complete

**Date**: January 27, 2025  
**Tunnel Token**: Provided  
**Container**: VMID 5000 on pve2

---

## ✅ Installation Command

**Run this on pve2 node:**

```bash
# Install cloudflared service with token
pct exec 5000 -- cloudflared service install eyJhIjoiNTJhZDU3YTcxNjcxYzVmYzAwOWVkZjA3NDQ2NTgxOTYiLCJ0IjoiYjAyZmUxZmUtY2I3ZC00ODRlLTkwOWItN2NjNDEyOThlYmU4IiwicyI6Ik5HTmtOV0kwWXpNdFpUVmxaUzAwTVRFMkxXRXdNMk10WlRJNU1ETTFaRFF4TURBMiJ9

# Start service
pct exec 5000 -- systemctl start cloudflared
pct exec 5000 -- systemctl enable cloudflared

# Verify installation
pct exec 5000 -- systemctl status cloudflared
pct exec 5000 -- cloudflared tunnel list
```

---

## 📋 What This Does

1. **Installs cloudflared** (if not already installed)
2. **Configures tunnel service** with the provided token
3. **Starts cloudflared service** automatically
4. **Enables service** to start on boot

---

## 🔍 After Installation

### Get Tunnel ID

```bash
pct exec 5000 -- cloudflared tunnel list
```

The tunnel ID will be displayed in the output.

### Configure DNS

**In Cloudflare Dashboard** (https://dash.cloudflare.com/):

1. Domain: **d-bis.org** → **DNS** → **Records**
2. Add CNAME:
   - **Name**: `explorer`
   - **Target**: `<tunnel-id>.cfargotunnel.com`
   - **Proxy**: 🟠 **Proxied** (orange cloud)
   - **TTL**: Auto

### Configure Tunnel Route

**In Cloudflare Zero Trust** (https://one.dash.cloudflare.com/):

1. **Zero Trust** → **Networks** → **Tunnels**
2. Find your tunnel → **Configure** → **Public Hostnames**
3. Add hostname:
   - **Subdomain**: `explorer`
   - **Domain**: `d-bis.org`
   - **Service**: `http://192.168.11.140:80`
   - **Type**: `HTTP`

---

## ✅ Verification

**Wait 1-5 minutes for DNS propagation, then:**

```bash
curl https://explorer.d-bis.org/api/v2/stats
```

**Expected**: JSON response with network stats (not 404)

---

## 🔧 Troubleshooting

### Service not starting

```bash
# Check logs
pct exec 5000 -- journalctl -u cloudflared -n 50

# Check status
pct exec 5000 -- systemctl status cloudflared
```

### Tunnel not connecting

- Verify token is valid
- Check Cloudflare Zero Trust dashboard for tunnel status
- Ensure DNS record is proxied (orange cloud)

---

**Status**: Ready to install  
**Next**: Run installation command above on pve2 node

