Cloudflare Docs
Spectrum
Visit Spectrum on GitHub
Set theme to dark (⇧+D)

Create CNAME records

The API supports specifying an origin by hostname, which is useful when setting up Spectrum in front of a load balancer, like an AWS ELB that offers a hostname instead of a static IP.

1. Create a CNAME record

You will need to create a CNAME record on your Cloudflare hosted zone that points to your origin’s hostname. This is required to resolve to your hostname origin.

API Example:

curl 'https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/dns_records'  \
-H 'Content-Type: application/json' \
-H 'X-Auth-Email: user@example.com' \
-H 'X-Auth-Key: 00000000000' \
-X POST --data '{"type":"CNAME", "name":"cname-to-origin.example.com", "content":"origin.domain.com", "proxied":true}'

Example Data:

{
  "type": "CNAME",
  "name": "cname-to-origin.example.com",
  "content": "origin.domain.com",
  "proxied": true
}

2. Create the Spectrum application

Next, create the Spectrum application that will point to the domain name. Below is an example curl and the associated data being posted to the API.

API Example:

curl -X POST 'https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/spectrum/apps' \
-H "Content-Type: application/json" \
-H "X-Auth-Email: email" \
-H "X-Auth-Key: key" \
--data '{"dns":{"type":"CNAME","name":"spectrum-cname.example.com"},"ip_firewall":false,"protocol":"tcp/22","proxy_protocol":"off","tls":"off","origin_dns": {"name": "cname-to-origin.example.com", "ttl": 1200}, "origin_port": 22}'

Example Data:

{
  "dns": {
    "type": "CNAME",
    "name": "spectrum-cname.example.com"
  },
  "ip_firewall": false,
  "protocol": "tcp/22",
  "proxy_protocol": "off",
  "tls": "off",
  "origin_dns": {
    "name": "cname-to-origin.example.com",
    "ttl": 1200
  },
  "origin_port": 22
}