# Cloudflare Domain Setup Guide

**Last Updated**: 2024-12-19

## Current Status

The domain `sankofa.nexus` is **not currently in your Cloudflare account**. You need to add it before DNS records can be created.

## Option 1: Add Domain to Cloudflare (Recommended)

### Steps

1. **Log in to Cloudflare Dashboard**
   - Go to: https://dash.cloudflare.com
   - Log in with: `pandoramannli@gmail.com`

2. **Add Domain**
   - Click "Add a Site" or "Add Site"
   - Enter: `sankofa.nexus`
   - Click "Add site"

3. **Choose Plan**
   - Select a plan (Free plan is sufficient for DNS)

4. **Update Nameservers**
   - Cloudflare will provide nameservers (e.g., `ns1.cloudflare.com`, `ns2.cloudflare.com`)
   - Update your domain registrar to use these nameservers
   - Wait for DNS propagation (can take up to 24 hours, usually much faster)

5. **Verify Domain is Active**
   - Once nameservers are updated, Cloudflare will show the domain as "Active"

6. **Get Zone ID**
   ```bash
   ./scripts/get-cloudflare-info.sh
   ```
   This will automatically retrieve and add the Zone ID to `.env`

7. **Create DNS Records**
   ```bash
   ./scripts/setup-dns-records.sh
   ```

## Option 2: Use Existing Domain

If you have another domain already in Cloudflare:

1. **Check Available Domains**
   ```bash
   source .env
   curl -s -X GET "https://api.cloudflare.com/client/v4/zones" \
     -H "X-Auth-Email: ${CLOUDFLARE_EMAIL}" \
     -H "X-Auth-Key: ${CLOUDFLARE_API_KEY}" | \
     jq -r '.result[] | "\(.name) - Zone ID: \(.id)"'
   ```

2. **Update Configuration**
   - Update `DOMAIN` in `.env` to use existing domain
   - Update all configuration files that reference `sankofa.nexus`

## Option 3: Use Subdomain

If you want to use a subdomain of an existing domain:

1. **Identify Parent Domain**
   - Check available zones (see Option 2)

2. **Create Subdomain Records**
   - Use the parent domain's Zone ID
   - Create records like `proxmox1.parent-domain.com`

3. **Update Configuration**
   - Update `DOMAIN` in `.env`
   - Update FQDNs in configuration files

## Verification

After adding the domain, verify it's accessible:

```bash
# Get Zone ID
./scripts/get-cloudflare-info.sh

# Check Zone ID in .env
grep ZONE_ID .env

# Create DNS records
./scripts/setup-dns-records.sh
```

## DNS Records to be Created

Once the domain is added, the script will create:

### For ml110-01 (192.168.11.10):
- `ml110-01.sankofa.nexus` → A record → 192.168.11.10
- `ml110-01-api.sankofa.nexus` → CNAME → ml110-01.sankofa.nexus
- `ml110-01-metrics.sankofa.nexus` → CNAME → ml110-01.sankofa.nexus

### For r630-01 (192.168.11.11):
- `r630-01.sankofa.nexus` → A record → 192.168.11.11
- `r630-01-api.sankofa.nexus` → CNAME → r630-01.sankofa.nexus
- `r630-01-metrics.sankofa.nexus` → CNAME → r630-01.sankofa.nexus

## Troubleshooting

### Domain Not Found
- **Issue**: Zone ID cannot be retrieved
- **Solution**: Add domain to Cloudflare account first

### Nameservers Not Updated
- **Issue**: Domain shows as "Pending" in Cloudflare
- **Solution**: Update nameservers at your domain registrar

### DNS Propagation Delay
- **Issue**: DNS records not resolving
- **Solution**: Wait for DNS propagation (usually 5-15 minutes, can take up to 24 hours)

### API Authentication Errors
- **Issue**: 401 or 403 errors
- **Solution**: Verify credentials in `.env` file are correct

## Next Steps

1. **Add Domain to Cloudflare** (if not already added)
2. **Update Nameservers** at domain registrar
3. **Wait for Activation** (domain status becomes "Active")
4. **Run Scripts**:
   ```bash
   ./scripts/get-cloudflare-info.sh
   ./scripts/setup-dns-records.sh
   ```
5. **Verify DNS Resolution**:
   ```bash
   dig ml110-01.sankofa.nexus
   dig r630-01.sankofa.nexus
   ```

## Related Documentation

- [Deployment Readiness](./DEPLOYMENT_READINESS.md)
- [Environment Variables](./ENVIRONMENT_VARIABLES.md)
- [DNS Configuration](./DNS_CONFIGURATION.md)

