Skip to content

Cloudflare Integration

Cloudflare Integration

Edge services binding the platform together.

Overview

Cloudflare provides the edge layer for all Pvdify services:

ServicePurpose
DNSDomain management for 49 zones
TLSSSL certificates (Full strict mode)
TunnelsSecure app ingress without public IPs
PagesStatic site hosting (Forge docs, Admin UI)
AccessZero Trust authentication
WAFWeb application firewall

Account Details

FieldValue
Accountverious.smith@philoveracity.com
Account ID4c0e79c7e403fe6e8d616ecca5564ee9
Zones49

CLI Tools

Three CLI tools available on the VPS:

flarectl (cf)

DNS and zone management:

Terminal window
# List zones
cf zone list
# List DNS records
cf dns list --zone example.com
# Create A record
cf dns create --zone example.com \
--type A --name @ \
--content 199.167.200.52 \
--proxy=true
# Create CNAME for tunnel
cf dns create --zone example.com \
--type CNAME --name app \
--content tunnel-id.cfargotunnel.com \
--proxy=true

Wrangler (cfw)

Workers, Pages, R2, KV:

Terminal window
# List Pages projects
cfw pages project list
# Deploy static site
cfw pages deploy ./dist --project-name myproject
# Manage Workers
cfw deploy
cfw tail
# R2 storage
cfw r2 bucket list

cloudflared

Tunnel management:

Terminal window
# Create tunnel
cloudflared tunnel create pvdify-apps
# Configure tunnel
cloudflared tunnel route dns pvdify-apps app.example.com
# Run tunnel
cloudflared tunnel run pvdify-apps
# List tunnels
cloudflared tunnel list

Tunnel Architecture

Cloudflare Tunnels provide secure ingress for containerized apps:

┌─────────────────────────────────────────────────────────────┐
│ Internet │
└──────────────────────────────┬──────────────────────────────┘
┌──────────────────────────────▼──────────────────────────────┐
│ Cloudflare Edge │
│ (TLS termination, WAF) │
└──────────────────────────────┬──────────────────────────────┘
│ Tunnel (encrypted)
┌──────────────────────────────▼──────────────────────────────┐
│ cloudflared │
│ (running on VPS) │
└──────────────────────────────┬──────────────────────────────┘
│ localhost
┌──────────────────────┼──────────────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ App 1 │ │ App 2 │ │ App 3 │
│ :3001 │ │ :3002 │ │ :3003 │
└─────────┘ └─────────┘ └─────────┘

Tunnel Configuration

Product-isolated tunnels:

TunnelPurposeConfig File
pvdifyPvdify control plane + apps/etc/cloudflared/pvdify.yml
wirebotWirebot Chat AI partner/etc/cloudflared/wirebot.yml
/etc/cloudflared/pvdify.yml
tunnel: <tunnel-id>
credentials-file: /root/.cloudflared/<tunnel-id>.json
ingress:
- hostname: pvdify.win
service: http://localhost:9443
- hostname: *.pvdify.win
service: http://localhost:9443
- hostname: myapp.com
service: http://localhost:3001
- hostname: api.myapp.com
service: http://localhost:3002
- service: http_status:404

Pvdify Tunnel Integration

When a domain is added to an app:

  1. pvdifyd calls Cloudflare API to create CNAME record
  2. pvdifyd updates cloudflared config with new ingress rule
  3. cloudflared reloads configuration
  4. Traffic routes through tunnel to app container
Terminal window
# Automated by pvdify domains:add
pvdify domains:add myapp newdomain.com
# Results in:
# 1. DNS: newdomain.com CNAME → tunnel-id.cfargotunnel.com
# 2. Tunnel: hostname: newdomain.com → http://localhost:3001

Cloudflare Access

Zero Trust authentication for internal services:

Protected Services

ServiceDomainAuth Method
Forge Docsforge.philoveracity.comEmail OTP
Admin UIpvdify.winEmail OTP
pvdifyd APIapi.pvdify.winService Token

Access Policies

Terminal window
# Create Access application
curl -X POST \
"https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/apps" \
-H "Authorization: Bearer $CF_TOKEN" \
-d '{
"name": "Pvdify Admin",
"domain": "pvdify.win",
"type": "self_hosted",
"session_duration": "24h"
}'
# Add email policy
curl -X POST \
"https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/apps/$APP_ID/policies" \
-H "Authorization: Bearer $CF_TOKEN" \
-d '{
"name": "Admin Access",
"decision": "allow",
"include": [{"email": {"email": "admin@philoveracity.com"}}]
}'

Cloudflare Pages

Static site hosting:

Active Projects

ProjectDomainContent
forge-philoveracityforge.philoveracity.comForge docs (Starlight)
pvdify-adminpvdify.winAdmin UI (SvelteKit)

Deployment

Terminal window
# Build and deploy
npm run build
cfw pages deploy ./dist --project-name forge-philoveracity
# Or via GitHub integration (automatic)
git push origin main

API Integration

pvdifyd uses Cloudflare API for:

OperationAPI Endpoint
Create DNS recordPOST /zones/{zone_id}/dns_records
Update DNS recordPATCH /zones/{zone_id}/dns_records/{id}
Delete DNS recordDELETE /zones/{zone_id}/dns_records/{id}
Purge cachePOST /zones/{zone_id}/purge_cache

Example: Add Domain

// pvdifyd internal flow
func (s *Service) AddDomain(app, domain string) error {
// 1. Get zone ID for domain
zoneID, err := s.cf.GetZoneID(domain)
// 2. Create CNAME record pointing to tunnel
_, err = s.cf.CreateDNSRecord(zoneID, DNSRecord{
Type: "CNAME",
Name: domain,
Content: s.tunnelHostname,
Proxied: true,
})
// 3. Update tunnel config
err = s.tunnel.AddIngress(domain, app.BindPort)
// 4. Reload cloudflared
return s.tunnel.Reload()
}

VPS IP Inventory

IPAssignmentCloudflare Status
199.167.200.52Main/Shared (WHM)Proxied (orange cloud)
199.167.201.52Available-
199.167.202.209Available-
199.167.203.234Available-
67.222.9.109thedream (dedicated)Proxied

One available IP will be dedicated to pvdify.win control plane.

Configuration Files

FilePurpose
~/.cloudflare/cloudflare.yamlflarectl config
/etc/cloudflared/pvdify.ymlPvdify tunnel config
/etc/cloudflared/wirebot.ymlWirebot tunnel config
/root/.cloudflared/*.jsonTunnel credentials
/usr/local/bin/cfflarectl wrapper
/usr/local/bin/cfwwrangler wrapper