# Cloudflare Explorer URL Configuration - Complete Guide

**Date**: January 27, 2025  
**Domain**: explorer.d-bis.org  
**Target**: http://192.168.11.140:80

---

## 🎯 Quick Configuration

### Step 1: Configure DNS Record (Cloudflare Dashboard)

1. **Go to**: https://dash.cloudflare.com/
2. **Select domain**: `d-bis.org`
3. **Navigate to**: **DNS** → **Records**
4. **Click**: **Add record** (or edit existing)

5. **Configure**:
   ```
   Type: CNAME
   Name: explorer
   Target: <tunnel-id>.cfargotunnel.com
   Proxy status: 🟠 Proxied (orange cloud) - REQUIRED
   TTL: Auto
   ```

6. **Click**: **Save**

**⚠️ CRITICAL**: Proxy status must be **🟠 Proxied** (orange cloud) for the tunnel to work!

---

### Step 2: Configure Tunnel Route (Cloudflare Zero Trust)

1. **Go to**: https://one.dash.cloudflare.com/
2. **Navigate to**: **Zero Trust** → **Networks** → **Tunnels**
3. **Find your tunnel** (look for tunnel ID or name)
4. **Click**: **Configure** button
5. **Click**: **Public Hostnames** tab
6. **Click**: **Add a public hostname**

7. **Configure**:
   ```
   Subdomain: explorer
   Domain: d-bis.org
   Service: http://192.168.11.140:80
   Type: HTTP
   ```

8. **Click**: **Save hostname**

---

## 🔍 Finding Your Tunnel ID

### Method 1: From Container

```bash
# SSH to Proxmox host
ssh root@192.168.11.10

# Enter container
pct exec 5000 -- bash

# Check config file
cat /etc/cloudflared/config.yml | grep tunnel

# Or list tunnels
cloudflared tunnel list
```

### Method 2: From Cloudflare Dashboard

1. Go to: https://one.dash.cloudflare.com/
2. Navigate to: **Zero Trust** → **Networks** → **Tunnels**
3. Your tunnel ID will be displayed in the tunnel list

---

## ✅ Verification

### Wait for DNS Propagation (1-5 minutes)

Then test:

```bash
# Test DNS resolution
dig explorer.d-bis.org
nslookup explorer.d-bis.org

# Should resolve to Cloudflare IPs (if proxied)

# Test HTTPS endpoint
curl -I https://explorer.d-bis.org
curl https://explorer.d-bis.org/api/v2/stats

# Should return Blockscout API response (not 404)
```

---

## 📋 Configuration Checklist

- [ ] DNS CNAME record created: `explorer` → `<tunnel-id>.cfargotunnel.com`
- [ ] DNS record is **🟠 Proxied** (orange cloud)
- [ ] Tunnel route configured: `explorer.d-bis.org` → `http://192.168.11.140:80`
- [ ] Cloudflared service running in container
- [ ] DNS propagated (wait 1-5 minutes)
- [ ] Public URL accessible: `https://explorer.d-bis.org`

---

## 🔧 Troubleshooting

### Issue: Public URL returns 404

**Possible Causes:**
1. DNS record not created
2. DNS record not proxied (gray cloud instead of orange)
3. Tunnel route not configured
4. Cloudflared service not running

**Solutions:**
1. Verify DNS record exists and is proxied
2. Check tunnel route in Zero Trust dashboard
3. Restart Cloudflared: `systemctl restart cloudflared` (inside container)

### Issue: Public URL returns 502

**Possible Causes:**
1. Tunnel route points to wrong IP/port
2. Nginx not running in container
3. Blockscout not running

**Solutions:**
1. Verify tunnel route: `http://192.168.11.140:80`
2. Check Nginx: `systemctl status nginx` (inside container)
3. Check Blockscout: `systemctl status blockscout` (inside container)

### Issue: DNS not resolving

**Possible Causes:**
1. DNS record not saved
2. DNS propagation delay
3. Wrong tunnel ID

**Solutions:**
1. Verify DNS record in Cloudflare dashboard
2. Wait 5-10 minutes for propagation
3. Verify tunnel ID matches DNS target

---

## 📝 Configuration Summary

| Setting | Value |
|---------|-------|
| **Domain** | explorer.d-bis.org |
| **DNS Type** | CNAME |
| **DNS Target** | `<tunnel-id>.cfargotunnel.com` |
| **Proxy Status** | 🟠 Proxied (required) |
| **Tunnel Service** | http://192.168.11.140:80 |
| **Tunnel Type** | HTTP |
| **Container IP** | 192.168.11.140 |
| **Container Port** | 80 (Nginx) |

---

## 🚀 Quick Setup Script

If you have Cloudflare API credentials, you can use:

```bash
cd /home/intlc/projects/proxmox
./scripts/configure-cloudflare-explorer-complete.sh
```

Or configure manually using the steps above.

---

**Status**: Ready for configuration  
**Next Step**: Follow Step 1 and Step 2 above in Cloudflare dashboards

