Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/spectrum/patterns.md
1## Common Use Cases23### 1. SSH Server Protection45**Terraform:**6```hcl7resource "cloudflare_spectrum_application" "ssh" {8zone_id = var.zone_id9protocol = "tcp/22"1011dns {12type = "CNAME"13name = "ssh.example.com"14}1516origin_direct = ["tcp://10.0.1.5:22"]17ip_firewall = true18argo_smart_routing = true19}20```2122**Benefits:** Hide origin IP, DDoS protection, IP firewall, Argo reduces latency2324### 2. Game Server2526**TypeScript (Minecraft):**27```typescript28const app = await client.spectrum.apps.create({29zone_id: 'your-zone-id',30protocol: 'tcp/25565',31dns: { type: 'CNAME', name: 'mc.example.com' },32origin_direct: ['tcp://192.168.1.10:25565'],33proxy_protocol: 'v1', // Preserves player IPs34argo_smart_routing: true,35});36```3738**Benefits:** DDoS protection, hide origin IP, Proxy Protocol for player IPs/bans, Argo reduces latency3940### 3. MQTT Broker4142IoT device communication.4344**TypeScript:**45```typescript46const mqttApp = await client.spectrum.apps.create({47zone_id: 'your-zone-id',48protocol: 'tcp/8883', // Use 1883 for plain MQTT49dns: { type: 'CNAME', name: 'mqtt.example.com' },50origin_direct: ['tcp://mqtt-broker.internal:8883'],51tls: 'full', // Use 'off' for plain MQTT52});53```5455**Benefits:** DDoS protection, hide broker IP, TLS termination at edge5657### 4. SMTP Relay5859Email submission (port 587). **WARNING**: See [gotchas.md](gotchas.md#smtp-reverse-dns)6061**Terraform:**62```hcl63resource "cloudflare_spectrum_application" "smtp" {64zone_id = var.zone_id65protocol = "tcp/587"6667dns {68type = "CNAME"69name = "smtp.example.com"70}7172origin_direct = ["tcp://mail-server.internal:587"]73tls = "full" # STARTTLS support74}75```7677**Limitations:**78- Spectrum IPs lack reverse DNS (PTR records)79- Many mail servers reject without valid rDNS80- Best for internal/trusted relay only8182### 5. Database Proxy8384MySQL/PostgreSQL. **Use with caution** - security critical.8586**PostgreSQL:**87```typescript88const postgresApp = await client.spectrum.apps.create({89zone_id: 'your-zone-id',90protocol: 'tcp/5432',91dns: { type: 'CNAME', name: 'postgres.example.com' },92origin_dns: { name: 'db-primary.internal.example.com' },93origin_port: 5432,94tls: 'strict', // REQUIRED95ip_firewall: true, // REQUIRED96});97```9899**MySQL:**100```hcl101resource "cloudflare_spectrum_application" "mysql" {102zone_id = var.zone_id103protocol = "tcp/3306"104105dns {106type = "CNAME"107name = "mysql.example.com"108}109110origin_dns {111name = "mysql-primary.internal.example.com"112}113114origin_port = 3306115tls = "strict"116ip_firewall = true117}118```119120**Security:**121- ALWAYS use `tls: "strict"`122- ALWAYS use `ip_firewall: true`123- Restrict to known IPs via zone firewall124- Use strong DB authentication125- Consider VPN or Cloudflare Access instead126127### 6. RDP (Remote Desktop)128129**Requires IP firewall.**130131**Terraform:**132```hcl133resource "cloudflare_spectrum_application" "rdp" {134zone_id = var.zone_id135protocol = "tcp/3389"136137dns {138type = "CNAME"139name = "rdp.example.com"140}141142origin_direct = ["tcp://windows-server.internal:3389"]143tls = "off" # RDP has own encryption144ip_firewall = true # REQUIRED145}146```147148**Security:** ALWAYS `ip_firewall: true`, whitelist admin IPs, RDP is DDoS/brute-force target149150### 7. Multi-Origin Failover151152High availability with load balancer.153154**Terraform:**155```hcl156resource "cloudflare_load_balancer" "database_lb" {157zone_id = var.zone_id158name = "db-lb.example.com"159default_pool_ids = [cloudflare_load_balancer_pool.db_primary.id]160fallback_pool_id = cloudflare_load_balancer_pool.db_secondary.id161}162163resource "cloudflare_load_balancer_pool" "db_primary" {164name = "db-primary-pool"165origins { name = "db-1"; address = "192.0.2.1" }166monitor = cloudflare_load_balancer_monitor.postgres_monitor.id167}168169resource "cloudflare_load_balancer_pool" "db_secondary" {170name = "db-secondary-pool"171origins { name = "db-2"; address = "192.0.2.2" }172monitor = cloudflare_load_balancer_monitor.postgres_monitor.id173}174175resource "cloudflare_load_balancer_monitor" "postgres_monitor" {176type = "tcp"; port = 5432; interval = 30; timeout = 5177}178179resource "cloudflare_spectrum_application" "postgres_ha" {180zone_id = var.zone_id181protocol = "tcp/5432"182dns { type = "CNAME"; name = "postgres.example.com" }183origin_dns { name = cloudflare_load_balancer.database_lb.name }184origin_port = 5432185tls = "strict"186ip_firewall = true187}188```189190**Benefits:** Automatic failover, health monitoring, traffic distribution, zero-downtime deployments191192## See Also193194- [configuration.md](configuration.md) - Origin type setup195- [gotchas.md](gotchas.md) - Protocol limitations196- [api.md](api.md) - SDK reference197