CDN management and integration plugin with multi-provider support, cache purging, HMAC-SHA256 signed URLs, bandwidth analytics, and zone management. Supports Cloudflare, BunnyCDN, Fastly, and Akamai.
Property
Value
Port
3036
Category
infrastructure
Multi-App
source_account_id (UUID)
Min nself
0.4.8
Quick Start
nself plugin run cdn init
nself plugin run cdn server
Configuration
Required Environment Variables
Variable
Description
DATABASE_URL
PostgreSQL connection string
Optional Environment Variables
Variable
Default
Description
CDN_PLUGIN_PORT
3036
Server port
CDN_PLUGIN_HOST
0.0.0.0
Server host
CDN_PROVIDER
cloudflare
Default CDN provider
CDN_CLOUDFLARE_API_TOKEN
-
Cloudflare API token
CDN_CLOUDFLARE_ZONE_IDS
-
Comma-separated Cloudflare zone IDs
CDN_BUNNYCDN_API_KEY
-
BunnyCDN API key
CDN_BUNNYCDN_PULL_ZONE_IDS
-
Comma-separated BunnyCDN pull zone IDs
CDN_SIGNING_KEY
-
HMAC-SHA256 key for signed URLs
CDN_SIGNED_URL_TTL
3600
Default signed URL TTL (seconds)
CDN_ANALYTICS_SYNC_INTERVAL
3600000
Analytics sync interval (ms)
CDN_PURGE_BATCH_SIZE
30
Maximum URLs per purge request
CDN_API_KEY
-
API key for plugin authentication
CDN_RATE_LIMIT_MAX
200
Max requests per window
CDN_RATE_LIMIT_WINDOW_MS
60000
Rate limit window (ms)
CLI Commands
Command
Description
init
Initialize database schema (4 tables, 3 views)
server
Start the HTTP API server
status
Show CDN plugin statistics
zones
Manage CDN zones (list, create, delete)
purge
Purge CDN cache (by URLs, tags, prefixes, or all)
sign
Generate signed URLs
analytics
View and sync analytics
REST API
Health & Status
Method
Path
Description
GET
/health
Health check
GET
/ready
Readiness check (DB)
GET
/live
Liveness with memory/uptime
Zones
Method
Path
Description
POST
/api/zones
Create zone (body: name, provider, domain, origin_url?, config?, enabled?)
Aggregates total bandwidth per zone with daily breakdown.
np_cdn_cache_hit_rate
Calculates cache hit rate percentage per zone: cache_hits / (cache_hits + cache_misses) * 100.
np_cdn_top_paths
Aggregates most-requested paths across all zones.
Troubleshooting
"CDN provider API key not configured" -- Set the appropriate CDN_CLOUDFLARE_API_TOKEN or CDN_BUNNYCDN_API_KEY for your provider.
Purge request fails -- Verify the zone exists and the provider API key has purge permissions. For Cloudflare, the token needs "Cache Purge" permission. Check CDN_PURGE_BATCH_SIZE if purging many URLs.
Signed URLs rejected -- Verify CDN_SIGNING_KEY is set and matches what the CDN edge is configured to validate. Check that the URL has not expired (expires parameter).
Analytics empty -- Run POST /sync to trigger an analytics sync from the provider. Verify the provider API key has analytics read permissions. Analytics sync runs automatically at CDN_ANALYTICS_SYNC_INTERVAL.
Zone not syncing -- Ensure the zone is enabled: true and the provider_zone_id matches the actual zone ID in the CDN provider dashboard.