Skip to main content

Create a CDN resource

A CDN resource connects an origin to CDB edge servers, which cache content and are hosted in geographically distributed data centers located closer to end users. An origin is required to create the resource in the CDB Technical Web Portal; create it during setup or reuse an existing origin group. To route production traffic through the CDN, access to the domain's DNS provider or registrar is required to complete the DNS setup, either by adding a CNAME record or by delegating the DNS zone.

  1. 1

    Open the creation form

    In the Customer Portal, navigate to CDN > CDN resources and click Create CDN resource.

    CDN resources list with the Create CDN resource button
  2. 2

    Select DNS management

    Select how traffic will be directed to the CDN:

    • Do not delegate keeps DNS at the current provider. After creating the resource, add a CNAME record that points the CDN subdomain to the *.gcdn.co value shown in the CDN resource's Setup guide.
    • Delegate your DNS zone to us uses delegated DNS to create or reuse a zone in CDB Managed DNS. After creating the resource, point the delegated zone to the CDB nameservers — at the registrar for a root domain, or as NS records in the parent zone for a subdomain.

    Select the DNS option before entering other form data. Switching between the options later clears the domain and origin values after confirmation.

  3. 3

    Add the domain

    In Add domain, enter the domain to deliver through the CDN:

    • For Do not delegate, enter a subdomain — cdn.example.com.
    • For delegated DNS, enter the domain whose DNS zone will be delegated — example.com or store.example.com.

    The primary CNAME cannot be edited after creation. To add more domains later, use Add CNAME in the resource settings.

    CDN creation form with domain and DNS management options
  4. 4

    (Optional) Enable WAAP

    Select Enable WAAP to add Web Application and API Protection, which provides Layer 7 DDoS protection and web application security. After creation, complete the WAAP setup.

    WAAP enabled with the Create and enable protection action
  5. 5

    Configure the origin

    The origin settings depend on the DNS option:

    • For Do not delegate, select Specify content origin to add an origin or Select origin group to reuse an existing origin group. A new origin can use a URL, S3 storage, or CDB EdgeCompute application. For CDB Object Storage, open the S3 storage tab, keep CDB selected, then choose a Storage and Bucket. Access keys are not entered. Create storage and Create bucket are available in those lists. Only Standard storage is supported. Egress from CDB Object Storage to the CDN is not billed. Amazon and Other still require access keys. Configure the port and host header when the origin requires non-default values, and click Add origin to add another source.
    • For delegated DNS, the portal resolves the domain to determine the origin. If no server address is found, enter it in Enter your origin IP so we can connect to your site.
    Origin configuration with URL, S3 storage, and CDB EdgeCompute options
  6. 6

    Create the resource

    Click Create. If WAAP is enabled, click Create and enable protection.

    With delegated DNS, a DNS zone already exists dialog can appear. Select Use existing zone to add the generated records to that zone, or Create separate zone to create an independent zone for the entered domain.

  7. 7

    Complete DNS setup

    Follow the instructions shown after creation for the selected DNS option.

    For Do not delegate, add a CNAME record at the DNS provider:

    FieldValue
    Name / HostThe entered subdomain — cdn.example.com
    Value / Points toThe *.gcdn.co value shown in the CDN resource's Setup guide

    Create one record for each custom domain.

    CNAME activation instructions with the generated CDB hostname

    For delegated DNS, point the zone to these CDB nameservers:

    ns1.gcorelabs.net
    ns2.gcdn.services
    
    • For a root domain (example.com), replace the current nameservers at the registrar with the CDB nameservers.
    • For a subdomain (store.example.com), add NS records for that subdomain in the parent DNS zone (example.com). Do not replace the parent domain's nameservers at the registrar.

    DNS updates can take up to 24 hours.

    Before integrating the resource with the website, open Setup guide in the CDN resource settings and click Check DNS setup status.

  8. 8

    Integrate the resource with the website

    For Do not delegate, update static file URLs to use the CDN subdomain — change example.com/images/image.jpg to cdn.example.com/images/image.jpg.

    Sites built on WordPress, Joomla, Drupal, or another CMS can use an integration plugin to replace domains in asset paths. The CMS integration guide lists supported systems.

    Delegated DNS routes the domain through the CDN after the nameserver update, so individual asset URLs do not need to be changed.

  9. 9

    (Optional) Add details and advanced settings

    Click Open resource settings. Add notes in Description, add more custom domains with Add CNAME, or configure other delivery settings.

Resource creation troubleshooting

If content is not served through the CDN after setup, verify the following:

  • The CNAME record, registrar nameservers, or parent-zone NS records match the values shown in the CDN resource's Setup guide.
  • DNS propagation has completed.
  • For Do not delegate, static file URLs use the CDN subdomain.

If the issue persists, contact CDB Support.

Create a CDN resource programmatically in two steps: create an origin group that defines the content origin, then create the CDN resource that ties a delivery subdomain to that origin. DNS setup is completed at the domain registrar or DNS provider after the resource is created.

An API token is required.

export GCORE_API_KEY="{YOUR_API_KEY}"

Quickstart

The scripts below create an origin group and CDN resource, then print the resource ID and delivery subdomain.

from gcore import CDB

client = CDB()  # Reads GCORE_API_KEY from env

# Step 1. Create an origin group
og = client.cdn.origin_groups.create(
    name="my-origin-group",
    sources=[{"source": "origin.example.com", "enabled": True}],
)

# Step 2. Create a CDN resource
resource = client.cdn.cdn_resources.create(
    cname="cdn.example.com",
    origin_group=og.id,
    origin_protocol="HTTPS",
)

print(f"Resource ID:    {resource.id}")
print(f"Delivery CNAME: {resource.cname}")
print(f"CNAME target:   {resource.id}.gcdn.co")
package main

import (
    "context"
    "fmt"

    gcore "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cdn"
)

func main() {
    client := gcore.NewClient()  // Reads GCORE_API_KEY from env
    ctx := context.Background()

    // Step 1. Create an origin group
    og, err := client.CDN.OriginGroups.New(ctx, cdn.OriginGroupNewParams{
        OfNoneAuth: &cdn.OriginGroupNewParamsBodyNoneAuth{
            Name: "my-origin-group",
            Sources: []cdn.OriginGroupNewParamsBodyNoneAuthSourceUnion{
                {OfHostSource: &cdn.OriginGroupNewParamsBodyNoneAuthSourceHostSource{
                    Source:  "origin.example.com",
                    Enabled: gcore.Bool(true),
                }},
            },
        },
    })
    if err != nil {
        panic(err)
    }

    // Step 2. Create a CDN resource
    resource, err := client.CDN.CDNResources.New(ctx, cdn.CDNResourceNewParams{
        Cname:          "cdn.example.com",
        OriginGroup:    gcore.Int(og.ID),
        OriginProtocol: cdn.CDNResourceNewParamsOriginProtocolHTTPS,
    })
    if err != nil {
        panic(err)
    }

    fmt.Printf("Resource ID:    %v\n", resource.ID)
    fmt.Printf("Delivery CNAME: %v\n", resource.Cname)
    fmt.Printf("CNAME target:   %v.gcdn.co\n", resource.ID)
}

Step 1. Create an origin group

An origin group defines the server that CDN edge servers fetch content from. Create one group per origin server; reuse an existing group across multiple CDN resources when the origin is shared.

ParameterRequiredDescription
nameYesUnique label for the group
sources[].sourceYesDomain or IP address of the origin server
sources[].enabledNoWhether this source is active. Defaults to true
from gcore import CDB

client = CDB()

og = client.cdn.origin_groups.create(
    name="my-origin-group",
    sources=[{"source": "origin.example.com", "enabled": True}],
)
print(og.id, og.name)
package main

import (
    "context"
    "fmt"

    gcore "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cdn"
)

func main() {
    client := gcore.NewClient()
    ctx := context.Background()

    og, err := client.CDN.OriginGroups.New(ctx, cdn.OriginGroupNewParams{
        OfNoneAuth: &cdn.OriginGroupNewParamsBodyNoneAuth{
            Name: "my-origin-group",
            Sources: []cdn.OriginGroupNewParamsBodyNoneAuthSourceUnion{
                {OfHostSource: &cdn.OriginGroupNewParamsBodyNoneAuthSourceHostSource{
                    Source:  "origin.example.com",
                    Enabled: gcore.Bool(true),
                }},
            },
        },
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(og.ID, og.Name)
}
curl -X POST "https://api.cdb-staging.cdn.orange.com/cdn/origin_groups" \
  -H "Authorization: APIKey $GCORE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-origin-group",
    "sources": [
      {"source": "origin.example.com", "enabled": true}
    ]
  }'

The API returns the created origin group:

{
  "id": 10001,
  "name": "my-origin-group",
  "sources": [
    {
      "source": "origin.example.com",
      "backup": false,
      "enabled": true
    }
  ],
  "use_next": true,
  "auth_type": "none"
}

Step 2. Create a CDN resource

The CDN resource ties the delivery subdomain to the origin group. The cname value becomes the DNS name that end users access; it must match the subdomain configured at the DNS provider. After creation, use the returned resource id to construct the CNAME DNS record target: {id}.gcdn.co.

ParameterRequiredDescription
cnameYesDelivery subdomain — cdn.example.com. Cannot be changed after creation
originGroupYesOrigin group ID from Step 1
originProtocolNoProtocol CDN servers use to fetch content: HTTP, HTTPS, or MATCH. Defaults to HTTP
from gcore import CDB

client = CDB()

resource = client.cdn.cdn_resources.create(
    cname="cdn.example.com",
    origin_group=10001,  # origin group ID from Step 1
    origin_protocol="HTTPS",
)
print(resource.id, resource.cname, resource.status)
package main

import (
    "context"
    "fmt"

    gcore "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cdn"
)

func main() {
    client := gcore.NewClient()
    ctx := context.Background()

    resource, err := client.CDN.CDNResources.New(ctx, cdn.CDNResourceNewParams{
        Cname:          "cdn.example.com",
        OriginGroup:    gcore.Int(10001),  // origin group ID from Step 1
        OriginProtocol: cdn.CDNResourceNewParamsOriginProtocolHTTPS,
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(resource.ID, resource.Cname, resource.Status)
}
curl -X POST "https://api.cdb-staging.cdn.orange.com/cdn/resources" \
  -H "Authorization: APIKey $GCORE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cname": "cdn.example.com",
    "originGroup": 10001,
    "originProtocol": "HTTPS"
  }'

The API returns the created CDN resource:

{
  "id": 12345,
  "cname": "cdn.example.com",
  "status": "processed",
  "active": true,
  "originGroup": 10001,
  "originProtocol": "HTTPS"
}

DNS setup

After the CDN resource is created, add a CNAME record at the domain's DNS provider to route traffic through the CDN. Use the id returned in Step 2 to determine the CNAME target.

DNS record fieldValue
TypeCNAME
Name / HostThe delivery subdomain — cdn.example.com
Value / Points to{resource_id}.gcdn.co — replace {resource_id} with the id returned in Step 2

DNS propagation takes up to 24 hours. To verify the record is live, run:

dig cdn.example.com CNAME +short

The output should show the {resource_id}.gcdn.co address.

Declare an origin group and a CDN resource that pulls that origin over HTTPS with the Terraform provider v2.

Create the CDN resource

The origin hostname must resolve in DNS. Set origin_protocol to HTTPS so edge servers fetch the origin over HTTPS.

resource "gcore_cdn_origin_group" "example" {
  name = "my-origin-group"

  sources = [
    {
      source  = "example.com"
      enabled = true
    }
  ]
}

resource "gcore_cdn_resource" "example" {
  cname           = "cdn.example.com"
  origin_group    = gcore_cdn_origin_group.example.id
  origin_protocol = "HTTPS"
}

output "cdn_resource_id" {
  value = gcore_cdn_resource.example.id
}

DNS setup

Apply prints cdn_resource_id. Add a CNAME record at the DNS provider. The target is that id with .gcdn.co appended.

DNS record fieldValue
TypeCNAME
Name / HostThe delivery subdomain — cdn.example.com
Value / Points to{resource_id}.gcdn.co. Replace {resource_id} with the printed cdn_resource_id value

Delete the CDN resource

Remove both resource blocks and the cdn_resource_id output. The next terraform apply deletes the CDN resource, then the origin group.

# Remove the CDN resource and the origin group:
# resource "gcore_cdn_origin_group" "example" {
#   name = "my-origin-group"
#
#   sources = [
#     {
#       source  = "example.com"
#       enabled = true
#     }
#   ]
# }
#
# resource "gcore_cdn_resource" "example" {
#   cname           = "cdn.example.com"
#   origin_group    = gcore_cdn_origin_group.example.id
#   origin_protocol = "HTTPS"
# }
#
# output "cdn_resource_id" {
#   value = gcore_cdn_resource.example.id
# }
terraform apply