Implements Action #1 from NEXT_ACTIONS_ALEXA.md: Complete Cloudflare DNS migration tooling and documentation for BlackRoad domains. New Features: - Automated DNS sync script (scripts/cloudflare/sync_dns.py) * Syncs DNS records from ops/domains.yaml to Cloudflare API * Supports dry-run mode for safe previewing * Handles CNAME, A, MX, and TXT records * Colored output for easy scanning - DNS validation script (scripts/cloudflare/validate_dns.py) * Verifies DNS resolution and propagation * Checks SSL certificate validity * Tests HTTP/HTTPS accessibility and redirects * Supports checking multiple domains - GitHub Actions workflow (.github/workflows/sync-cloudflare-dns.yml) * Automatically syncs DNS on ops/domains.yaml changes * Includes dry-run validation step * Manual trigger support via workflow_dispatch Documentation: - Comprehensive migration guide (docs/CLOUDFLARE_MIGRATION_GUIDE.md) * Step-by-step instructions for migrating from GoDaddy to Cloudflare * Covers all 10 BlackRoad domains * Includes troubleshooting and rollback procedures * Estimated 2-4 hours total migration time - Scripts README (scripts/cloudflare/README.md) * Installation and usage instructions * API token setup guide * Integration examples for CI/CD Configuration: - Updated backend/.env.example with Cloudflare variables: * CLOUDFLARE_API_TOKEN * CLOUDFLARE_ACCOUNT_ID * CLOUDFLARE_ZONE_ID * CLOUDFLARE_EMAIL - Python dependencies (scripts/cloudflare/requirements.txt) * requests, PyYAML, dnspython, colorama Benefits of Cloudflare Migration: - Free SSL certificates with automatic renewal - Global CDN for faster page loads - DDoS protection and Web Application Firewall - Better DNS performance via anycast network - Advanced features (Workers, Zero Trust, edge functions) - Superior analytics and security insights Next Steps: 1. Set up Cloudflare account and get API token 2. Add blackroad.systems domain to Cloudflare 3. Update nameservers at GoDaddy 4. Run sync script to configure DNS records 5. Verify migration with validation script 6. Repeat for remaining 9 domains Related: - Implements infra/cloudflare/CLOUDFLARE_DNS_BLUEPRINT.md - Addresses ops/DOMAIN_FIX_GUIDE.md recommendations - Part of Phase 1 Q1 infrastructure foundation Files Added: - scripts/cloudflare/sync_dns.py (352 lines) - scripts/cloudflare/validate_dns.py (387 lines) - scripts/cloudflare/README.md - scripts/cloudflare/requirements.txt - docs/CLOUDFLARE_MIGRATION_GUIDE.md (867 lines) - .github/workflows/sync-cloudflare-dns.yml Files Modified: - backend/.env.example (added Cloudflare env vars)
19 KiB
Cloudflare DNS Migration Guide
Complete Step-by-Step Guide for BlackRoad Domains
Version: 1.0 Date: 2025-11-18 Estimated Time: 2-4 hours for all domains Skill Level: Intermediate
Overview
This guide walks you through migrating BlackRoad domains from GoDaddy DNS to Cloudflare DNS. The migration provides:
- ✅ Free SSL certificates (automatic renewal)
- ✅ Global CDN (faster page loads worldwide)
- ✅ DDoS protection (automatic threat mitigation)
- ✅ Better DNS performance (anycast network)
- ✅ Advanced features (Workers, Zero Trust, edge functions)
- ✅ Superior analytics (traffic insights, security events)
What you'll need:
- Cloudflare account (free tier is sufficient)
- GoDaddy account with domain access
- 2-4 hours of time
- Basic command line familiarity (optional, for automation)
Table of Contents
- Pre-Migration Checklist
- Phase 1: Set Up Cloudflare Account
- Phase 2: Add Domains to Cloudflare
- Phase 3: Update Nameservers at GoDaddy
- Phase 4: Configure DNS Records
- Phase 5: Configure SSL/TLS
- Phase 6: Optimize Performance
- Phase 7: Verify Migration
- Phase 8: Automation Setup (Optional)
- Troubleshooting
- Rollback Plan
Pre-Migration Checklist
Before starting, gather this information:
- GoDaddy credentials - Username and password
- Current DNS records - Document existing configuration
- Email access - For Cloudflare verification
- Railway hostname - Your production app URL (e.g.,
your-app.up.railway.app) - Current uptime - Note if services are running properly
⚠️ Important Notes:
- Migration happens with zero downtime if done correctly
- DNS propagation takes 5-60 minutes (sometimes up to 24 hours)
- Keep GoDaddy account active (domain registration stays there)
- Only DNS management moves to Cloudflare
Phase 1: Set Up Cloudflare Account
Step 1.1: Create Cloudflare Account
- Go to https://dash.cloudflare.com/sign-up
- Enter your email address
- Create a strong password
- Verify your email address
Step 1.2: Two-Factor Authentication (Recommended)
- Click on your profile (top right)
- Go to My Profile → Authentication
- Enable Two-Factor Authentication
- Save backup codes in a secure location
Step 1.3: Get API Token
- Go to My Profile → API Tokens
- Click Create Token
- Select Edit zone DNS template
- Configure permissions:
- Zone - DNS - Edit
- Zone - Zone - Read
- Select Specific zones → (you'll add zones in Phase 2)
- Click Continue to summary → Create Token
- Copy the token immediately (you won't see it again!)
- Save it securely (we'll use it later for automation)
Phase 2: Add Domains to Cloudflare
We'll start with the primary domain (blackroad.systems) and then add others.
Step 2.1: Add blackroad.systems
- From Cloudflare dashboard, click Add a site
- Enter:
blackroad.systems - Click Add site
- Select Free plan → Click Continue
- Cloudflare will scan existing DNS records from GoDaddy
- Wait 30-60 seconds for scan to complete
Step 2.2: Review Scanned Records
Cloudflare should detect existing records. Review them:
- ✅ Check for A records pointing to your server
- ✅ Check for CNAME records
- ✅ Check for MX records (email)
- ✅ Check for TXT records (SPF, verification)
Common issues:
- Some records might be missing → We'll add them manually later
- TTL values might be high → We'll adjust them
Step 2.3: Get Nameservers
After scanning, Cloudflare will show 2 nameservers like:
aaaa.ns.cloudflare.com
bbbb.ns.cloudflare.com
⚠️ IMPORTANT: Copy these nameservers! You'll need them in Phase 3.
Don't click "Done" yet - we'll do that after updating nameservers at GoDaddy.
Phase 3: Update Nameservers at GoDaddy
⏰ Estimated Time: 10 minutes + 5-60 minutes propagation
Step 3.1: Log in to GoDaddy
- Go to https://account.godaddy.com
- Sign in with your credentials
- Go to My Products → Domains
Step 3.2: Update Nameservers for blackroad.systems
- Find
blackroad.systemsin your domain list - Click the three dots (...) → Manage DNS
- Scroll down to Nameservers section
- Click Change → Select Enter my own nameservers (advanced)
- Remove existing nameservers
- Add the 2 Cloudflare nameservers from Phase 2, Step 2.3:
aaaa.ns.cloudflare.com bbbb.ns.cloudflare.com - Click Save
- Confirm the change
What happens now:
- GoDaddy will propagate the nameserver change
- This takes 5-60 minutes (sometimes up to 24 hours)
- Your site will continue working during this time
Step 3.3: Return to Cloudflare
- Go back to Cloudflare dashboard
- Click Done, check nameservers
- Cloudflare will start checking for nameserver changes
- You'll see status: Pending Nameserver Update
⏳ Wait time: 5-60 minutes for Cloudflare to detect the change
You can check status by:
- Refreshing the Cloudflare dashboard
- Running:
dig NS blackroad.systems(should show Cloudflare nameservers) - Using: https://dnschecker.org
Phase 4: Configure DNS Records
Once Cloudflare shows Active status, configure DNS records.
Step 4.1: Verify Existing Records
- In Cloudflare dashboard, go to DNS → Records
- Review scanned records
- Remove any incorrect or outdated records
Step 4.2: Add/Update Primary Records
Root Domain (blackroad.systems)
| Type | Name | Target | Proxy | TTL |
|---|---|---|---|---|
| CNAME | @ | your-app.up.railway.app |
✅ Proxied | Auto |
Steps:
- Click Add record
- Type: CNAME
- Name: @ (represents root domain)
- Target: your-railway-app.up.railway.app (replace with actual Railway URL)
- Proxy status: Proxied (orange cloud icon)
- TTL: Auto
- Click Save
WWW Subdomain
| Type | Name | Target | Proxy | TTL |
|---|---|---|---|---|
| CNAME | www | blackroad.systems | ✅ Proxied | Auto |
Steps:
- Click Add record
- Type: CNAME
- Name: www
- Target: blackroad.systems
- Proxy status: Proxied
- Click Save
API Subdomain
| Type | Name | Target | Proxy | TTL |
|---|---|---|---|---|
| CNAME | api | your-app.up.railway.app |
✅ Proxied | Auto |
OS Subdomain
| Type | Name | Target | Proxy | TTL |
|---|---|---|---|---|
| CNAME | os | blackroad.systems | ✅ Proxied | Auto |
Step 4.3: Configure Email Records (If Applicable)
If you use Google Workspace, G Suite, or custom email:
SPF Record
| Type | Name | Content | TTL |
|---|---|---|---|
| TXT | @ | v=spf1 include:_spf.google.com ~all |
Auto |
MX Records
| Type | Name | Content | Priority | TTL |
|---|---|---|---|---|
| MX | @ | aspmx.l.google.com | 1 | Auto |
| MX | @ | alt1.aspmx.l.google.com | 5 | Auto |
| MX | @ | alt2.aspmx.l.google.com | 5 | Auto |
Step 4.4: Verify Records
# Check DNS resolution
dig blackroad.systems
dig www.blackroad.systems
dig api.blackroad.systems
# Or use Cloudflare dashboard DNS checker
Phase 5: Configure SSL/TLS
Step 5.1: Set Encryption Mode
- In Cloudflare dashboard, go to SSL/TLS
- Set Encryption mode to Full (strict)
- This ensures encryption between Cloudflare and Railway
- Railway automatically provides SSL certificates
⚠️ Important: Do NOT use "Flexible" mode (insecure)
Step 5.2: Enable Always Use HTTPS
- Go to SSL/TLS → Edge Certificates
- Enable Always Use HTTPS
- This redirects all HTTP traffic to HTTPS
- Enable Automatic HTTPS Rewrites
- Fixes mixed content warnings
Step 5.3: Enable HSTS (Optional but Recommended)
- Still in Edge Certificates
- Enable HTTP Strict Transport Security (HSTS)
- Configuration:
- Max Age: 6 months (15768000 seconds)
- Include subdomains: ✅ Enabled
- Preload: ❌ Disabled (enable later when stable)
- No-Sniff header: ✅ Enabled
⚠️ Warning: HSTS is irreversible for the max-age period. Only enable when confident.
Step 5.4: Enable TLS 1.3
- Go to SSL/TLS → Edge Certificates
- Minimum TLS Version: Set to TLS 1.2 (or 1.3 if supported)
- TLS 1.3: ✅ Enabled
Step 5.5: Verify SSL Configuration
- Visit:
https://blackroad.systems - Click the padlock icon in browser
- Verify certificate is valid and issued by Cloudflare
- Check expiry date (should auto-renew)
Test with SSL Labs:
https://www.ssllabs.com/ssltest/analyze.html?d=blackroad.systems
Phase 6: Optimize Performance
Step 6.1: Configure Caching
- Go to Caching → Configuration
- Caching Level: Standard
- Browser Cache TTL: Respect Existing Headers
Step 6.2: Enable Auto Minify
- Go to Speed → Optimization
- Enable Auto Minify:
- ✅ JavaScript
- ✅ CSS
- ✅ HTML
Step 6.3: Enable Brotli Compression
- Still in Speed → Optimization
- Enable Brotli compression (better than gzip)
Step 6.4: Create Page Rules
- Go to Rules → Page Rules
- Create rule for API bypass:
Rule 1: API Cache Bypass
URL: *blackroad.systems/api/*
Settings:
- Cache Level: Bypass
Rule 2: WWW Redirect
URL: www.blackroad.systems/*
Settings:
- Forwarding URL: 301 redirect to https://blackroad.systems/$1
Note: Free plan allows 3 page rules. Use them wisely!
Phase 7: Verify Migration
Step 7.1: DNS Verification
# Check DNS propagation
dig blackroad.systems
# Check with multiple tools
dig @8.8.8.8 blackroad.systems
dig @1.1.1.1 blackroad.systems
# Or use online tool
# https://dnschecker.org
Expected results:
- Should resolve to Cloudflare IP addresses
- CNAME records should point to Railway
- Nameservers should be Cloudflare
Step 7.2: HTTP/HTTPS Verification
# Test HTTP → HTTPS redirect
curl -I http://blackroad.systems
# Should return: 301 Moved Permanently
# Location: https://blackroad.systems/
# Test HTTPS
curl -I https://blackroad.systems
# Should return: 200 OK
# Test WWW → apex redirect
curl -I https://www.blackroad.systems
# Should redirect to https://blackroad.systems
Step 7.3: SSL Certificate Check
# Check SSL certificate
openssl s_client -connect blackroad.systems:443 -servername blackroad.systems
# Look for:
# - Issuer: Cloudflare
# - Valid dates
# - No errors
Step 7.4: Application Functionality
- Visit
https://blackroad.systems - Test all major features:
- Page loads correctly
- No mixed content warnings
- API calls work
- Authentication works
- Static assets load (CSS, JS, images)
Step 7.5: Automated Validation
# Use the validation script
cd /path/to/BlackRoad-Operating-System
python scripts/cloudflare/validate_dns.py --domain blackroad.systems
# This checks:
# - DNS resolution
# - SSL certificate validity
# - HTTP accessibility
# - Redirect configuration
Phase 8: Automation Setup (Optional)
Step 8.1: Install Script Dependencies
# Navigate to project
cd /path/to/BlackRoad-Operating-System
# Install Python dependencies
pip install -r scripts/cloudflare/requirements.txt
Step 8.2: Set Up Environment Variables
# Create .env file (DO NOT COMMIT)
cat >> .env << EOF
CF_API_TOKEN=your-cloudflare-api-token
CF_ZONE_ID=your-zone-id
EOF
# Or add to shell profile
echo 'export CF_API_TOKEN="your-token"' >> ~/.bashrc
echo 'export CF_ZONE_ID="your-zone-id"' >> ~/.bashrc
source ~/.bashrc
Step 8.3: Update domains.yaml
Edit ops/domains.yaml to reflect your Cloudflare configuration:
domains:
- name: "blackroad.systems"
type: "root"
provider: "cloudflare"
mode: "dns"
record:
type: "CNAME"
value: "your-actual-railway-app.up.railway.app"
proxied: true
- name: "blackroad.ai"
type: "root"
provider: "cloudflare"
mode: "dns"
record:
type: "CNAME"
value: "blackroad.systems"
proxied: true
Step 8.4: Test Automation
# Dry run (shows what would change)
python scripts/cloudflare/sync_dns.py --dry-run
# Apply changes
python scripts/cloudflare/sync_dns.py
# Validate
python scripts/cloudflare/validate_dns.py --all
Step 8.5: Set Up GitHub Actions (Optional)
Add secrets to GitHub:
gh secret set CF_API_TOKEN
gh secret set CF_ZONE_ID
Create workflow file (.github/workflows/sync-cloudflare-dns.yml):
name: Sync Cloudflare DNS
on:
push:
paths:
- 'ops/domains.yaml'
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install -r scripts/cloudflare/requirements.txt
- run: python scripts/cloudflare/sync_dns.py
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
Troubleshooting
Issue: DNS Not Resolving
Symptoms: dig blackroad.systems returns no results
Causes:
- Nameservers not updated at GoDaddy
- DNS propagation not complete
- Records not configured in Cloudflare
Solutions:
- Check nameservers at GoDaddy
- Wait 5-60 minutes for propagation
- Check Cloudflare zone status (should be "Active")
- Verify DNS records exist in Cloudflare
Issue: SSL Certificate Errors
Symptoms: Browser shows "Not Secure" or certificate warning
Causes:
- SSL/TLS mode incorrect
- Railway app doesn't have valid certificate
- Certificate provisioning in progress
Solutions:
- Set SSL/TLS mode to "Full (strict)"
- Verify Railway app has SSL
- Wait 5-10 minutes for certificate provisioning
- Clear browser cache and retry
Issue: Site Not Loading (403/502 Errors)
Symptoms: Site returns 403 Forbidden or 502 Bad Gateway
Causes:
- Railway app not running
- Incorrect CNAME target
- Cloudflare firewall blocking
Solutions:
- Check Railway app status and logs
- Verify CNAME points to correct Railway URL
- Check Cloudflare firewall rules
- Disable Cloudflare proxy temporarily (DNS-only) to test
Issue: Mixed Content Warnings
Symptoms: Some assets load as insecure (http://)
Causes:
- Hard-coded HTTP URLs in code
- External resources using HTTP
Solutions:
- Enable "Automatic HTTPS Rewrites" in Cloudflare
- Update hard-coded URLs to HTTPS
- Use protocol-relative URLs:
//example.com/asset.js
Issue: Email Not Working
Symptoms: Emails not sending/receiving
Causes:
- MX records not migrated
- SPF/DKIM records missing
Solutions:
- Add MX records in Cloudflare (from Phase 4.3)
- Add SPF TXT record
- Add DKIM records if using custom email
- Verify with:
dig MX blackroad.systems
Rollback Plan
If you need to revert to GoDaddy DNS:
Quick Rollback
- Go to GoDaddy → Domains → blackroad.systems
- Nameservers → Change to GoDaddy defaults
- Wait 5-60 minutes for propagation
- Site will revert to GoDaddy DNS
⚠️ Note: You can keep the Cloudflare account and try again later.
Gradual Rollback
If experiencing issues but want to keep trying:
- In Cloudflare, change proxy status to DNS Only (gray cloud)
- This bypasses Cloudflare's proxy but keeps DNS
- Troubleshoot issues
- Re-enable proxy when fixed
Next Steps After Migration
For All Remaining Domains
Repeat the process for:
- blackroad.ai
- blackroad.network
- blackroad.me
- lucidia.earth
- aliceqi.com
- blackroadqi.com
- roadwallet.com
- aliceos.io
- blackroadquantum.com
Pro tip: After doing blackroad.systems, the others are easier!
Monitoring and Maintenance
-
Set up monitoring:
- Uptime monitoring (UptimeRobot, Pingdom)
- SSL certificate expiry monitoring
- Performance monitoring (Cloudflare Analytics)
-
Review quarterly:
- DNS records (remove unused)
- Page rules and caching
- Security settings
- Analytics and performance
-
Stay updated:
- Review Cloudflare changelog
- Test new features in sandbox
- Keep API tokens rotated
Migration Checklist
Use this to track your progress:
Pre-Migration
- GoDaddy credentials ready
- Current DNS records documented
- Railway hostname confirmed
- Cloudflare account created
Cloudflare Setup
- API token generated and saved
- Domain added to Cloudflare
- DNS records scanned
- Nameservers noted
GoDaddy Update
- Nameservers updated at GoDaddy
- Change confirmed
- Propagation completed (zone shows "Active")
DNS Configuration
- Root domain CNAME added
- WWW subdomain added
- API subdomain added
- OS subdomain added
- Email records added (if applicable)
SSL/TLS
- Encryption mode set to Full (strict)
- Always Use HTTPS enabled
- Automatic HTTPS Rewrites enabled
- HSTS configured (optional)
- TLS 1.3 enabled
Performance
- Auto Minify enabled
- Brotli compression enabled
- Page rules configured
- Caching configured
Verification
- DNS resolution verified
- SSL certificate valid
- HTTP → HTTPS redirect working
- WWW → apex redirect working
- Site accessible and functional
- API endpoints working
- Email working (if applicable)
Automation (Optional)
- Python dependencies installed
- Environment variables set
- domains.yaml updated
- Automation scripts tested
- GitHub Actions configured (optional)
Resources
Documentation
External Links
Support
- Cloudflare Community: https://community.cloudflare.com/
- Railway Discord: https://discord.gg/railway
- BlackRoad GitHub Issues: https://github.com/blackboxprogramming/BlackRoad-Operating-System/issues
Congratulations! 🎉
You've successfully migrated to Cloudflare DNS. Your sites now benefit from:
- Global CDN and faster performance
- Free SSL with auto-renewal
- DDoS protection
- Advanced security features
- Better analytics and insights
Questions or issues? Check the troubleshooting section or open a GitHub issue.
Last Updated: 2025-11-18 Maintainer: BlackRoad DevOps Team Version: 1.0