Custom origins overview

Use custom origins for Cloud CDN when content is hosted on-premises or in another cloud, and you want to deliver the content over Google's high performance, distributed edge caching infrastructure.

The terms "custom origin," "external endpoint," and "internet endpoint" are often used interchangeably because they have the same meaning. In CDN, "origin" is the industry-standard term for a backend instance that serves web content. This document uses the term custom origin.

Supported origins for Cloud CDN

The Cloud CDN (content delivery network) works with HTTP(S) Load Balancing to deliver content to your users. The external HTTP(S) load balancer provides the frontend IP addresses and ports that receive requests. Cloud CDN content can be sourced from various types of backends:

Hybrid and multi-cloud architectures

As you move your services to Google Cloud, you might need to do so in phases. Sometimes, certain content can't immediately be moved to a cloud environment and might need to stay on-premises. In other cases, the content might be hosted in another cloud. Cloud CDN support for custom origins enables you to use Google's globally distributed edge caching infrastructure for such content.

Hybrid and multicloud architecture
Hybrid and multicloud architecture

In the example, images content resides in Google Cloud, while video resides in a Tokyo data center, which could be on premises or in another cloud. With custom origins, origins in the Tokyo data center can be the backend source of the video content with Cloud CDN and HTTP(S) Load Balancing delivering the content to users.

Using URL maps, this deployment can direct origin pull requests for video traffic to the custom origin in Tokyo. This mapping is determined based on request URL: /video.

For images (determined based on request URL: /images), content is sourced from Google Cloud and is delivered by the Cloud CDN edge infrastructure.

Cloud CDN and load balancing caveat

Cloud CDN supports fetching content from a single custom origin for a service. It does not provide load balancing among multiple custom origins for a service, nor does it load balance between a custom origin and a Google Cloud backend.

Specifying a custom origin

Similar to configuring Cloud CDN with your endpoints deployed in Google Cloud, you can use the network endpoint groups (NEGs) API to add your server as the custom origin for Cloud CDN.

You need to use an internet NEG to specify the custom origin. An internet NEG has one of the following endpoint types:

Endpoint address Type Definition When to use
Hostname and an optional port INTERNET_FQDN_PORT A publicly resolvable fully qualified domain name and an optional port, for example backend.example.com:443 (default ports: 80 for HTTP and 443) Use this endpoint when your external origin can be resolved through a fully-qualified domain name with public DNS.
IP address and an optional port INTERNET_IP_PORT A publicly accessible IP address and an optional port, for example 8.8.8.8 or 8.8.8.8:443 (default ports: 80 for HTTP and 443) Use this endpoint to specify a publicly accessible IP address and a port to connect to.

The best practice is to create the internet NEG with the INTERNET_FQDN_PORT endpoint type and an FQDN value as an origin hostname value. This insulates the Cloud CDN configuration from IP address changes in the origin infrastructure. Network endpoints that are defined using FQDNs are resolved through public DNS. Make sure that the configured FQDN is resolvable through Google Public DNS.

Note that once created, the type cannot be changed between INTERNET_FQDN_PORT and INTERNET_IP_PORT. You will need to create a new internet NEG and change your backend service to use the new internet NEG.

When using a custom origin that expects a particular value for the HTTP request's Host header, you must configure the backend service to set the Host header to that expected value. If you don't configure a user-defined request header, a backend service preserves the Host header that the client used to connect to the Google Cloud external HTTP(S) load balancer. For general information about user-defined request headers, see Creating user-defined request headers. For a specific example, see Configuring a load balancer with a custom origin.

For Cloud CDN to cache the responses from your origin, your origin must meet the existing Cloud CDN requirements for caching, such as setting valid Cache-Control headers in responses to Cloud CDN and the external HTTP(S) load balancer.

Using custom origins and Google Cloud-based origins

The following figure shows an internet NEG used to deploy a custom origin with HTTP(S) Load Balancing and Cloud CDN.

Cloud CDN with custom origins and NEGs
Cloud CDN with custom origins and NEGs

For more information, see Internet network endpoint groups overview.

What's next