You can configure origins for Media CDN in many ways. This page shows you how to configure origins.
Configure a Cloud Storage bucket as an origin
Media CDN supports Cloud Storage buckets as backends for content. Each service can reference multiple buckets by configuring routes for host, paths, and other request attributes.
Cloud Storage buckets are configured by using the bucket URL, such as
gs://my-bucket, as the origin address when creating an origin resource.
Console
In the Google Cloud console, go to the Media CDN page.
Click the Origins tab.
Click Create origin.
Enter a name for the origin. For example:
cloud-storage-origin.Optional: Enter a description.
For the Origin address, choose Select a Google Cloud Storage bucket.
Browse to your Cloud Storage bucket and select it.
For Cloud Storage, retain the default protocol and port settings.
Optional: For origin request header overrides to take precedence over headers sent by the client or manipulated by route-level header actions, do the following:
- Select Enable origin override.
- In the Headers section, specify headers by adding one or more name-value pairs.
Optional: Select a failover origin to try in case this origin becomes unreachable. You can update this field later.
Select redirect conditions.
Select retry conditions.
For Max attempts, select the maximum number of attempts to fill cache from this origin.
Optional: Specify the following timeout values:
- For Connect timeout, select the maximum duration to wait for the origin connection to be established.
- For Response timeout, select the maximum duration to allow for a response to complete.
- For Read timeout, select the maximum duration to wait between reads of a single HTTP connection or stream.
Optional: Click Add label and specify one or more key-value pairs.
Click Create origin.
gcloud
Use the gcloud edge-cache origins create command:
gcloud edge-cache origins create ORIGIN \
--origin-address=ADDRESS
Replace the following:
ORIGIN: the name of the new originADDRESS: the bucket name—for example,gs://my-bucket
This is the same whether the bucket is multi-regional, dual-region, or regional.
When configuring a service, you can route your video-on-demand content to one
bucket and live streaming content to a second bucket. This is useful if you have
different teams managing each workflow. To reduce cache fill latency, you can
similarly route the eu-media.example.com region to a multiregional
Cloud Storage bucket located in the EU and the us-media.example.com
region (or match on path, header, or query parameter) to a US-based storage
bucket.
For cases where write latency is critical, such as low-latency live streaming, you can configure a regional Cloud Storage endpoint as close to your users as possible.
Authenticate requests
To confirm that a request is coming from Media CDN, use one of the following supported approaches:
- Validate that the connecting IP address is from Media CDN's
cache fill ranges. These ranges are shared across all customers, but are
always used by
EdgeCacheServiceresources when connecting to an origin. - Add a custom request header with a token value that you validate on the origin (for example, a random 16-byte value). Your origin can then reject requests that don't include this value.
Configure an origin protocol
If your origin supports HTTP/2, you don't need to explicitly set the protocol.
For origins that support only HTTPS (HTTP/1.1 over TLS) or HTTP/1.1 (without
TLS), set the protocol field explicitly by doing the following:
Console
In the Google Cloud console, go to the Media CDN page.
Click the Origins tab.
Select your origin and click Edit.
For the protocol, select HTTPS or HTTP. For HTTP, also specify the port as
80.Click Update origin.
gcloud
Use the gcloud edge-cache origins update command:
gcloud edge-cache origins update LEGACY_ORIGIN \
--protocol=HTTPS
Replace LEGACY_ORIGIN with the name of the origin.
Configure private Cloud Storage buckets
Media CDN can pull content from any internet-reachable HTTP or HTTPS endpoint. In some cases, you might want to require authentication, in order to only allow Media CDN to pull content, and prevent unauthorized access. Cloud Storage supports this through IAM permissions.
For Cloud Storage origins, do the following:
- Grant the Media CDN service account the
objectViewerIAM permission on the Cloud Storage buckets you are using as your origins. - Remove the
allUserspermission. - Optional: Remove the
allAuthenticatedUserspermission.
To change permissions of a Cloud Storage bucket, you need the
Storage Admin role
(roles/storage.admin).
The Media CDN service account is owned by the Media CDN project, and it won't appear in your project's list of service accounts. The service account grants access only to Media CDN resources in the projects that you explicitly allow.
You must create at least one Media CDN resource to trigger
service account creation. In most cases, this is the EdgeCacheOrigin resource
connected to your Cloud Storage bucket.
To grant Media CDN access to a bucket, grant the objectViewer
role to the service account:
gcloud storage buckets add-iam-policy-binding gs://BUCKET \
--member=serviceAccount:service-PROJECT_NUMBER@gcp-sa-mediaedgefill.iam.gserviceaccount.com \
--role=roles/storage.objectViewer
Replace PROJECT_NUMBER with the project number.
Before removing public access to an existing storage bucket used as a production origin, allow at least 10 minutes for the configuration to propagate.
Use the gcloud storage buckets remove-iam-policy-binding command
to remove permissions granted to the allUsers role for the given bucket. For
example, if the bucket grants allUsers the objectViewer role, remove the
grant using the following command:
gcloud storage buckets remove-iam-policy-binding gs://BUCKET \
--member=allUsers --role=roles/storage.objectViewer
To validate that public access has been removed, open an incognito
browser window and attempt to access a bucket object by using
https://storage.googleapis.com/BUCKET/object.ext.
To allow EdgeCacheService resources within one project access
to a Cloud Storage bucket in another project, you can grant the
Media CDN service account in that project access to the storage
bucket.
To do so, verify that PROJECT_NUMBER in
service-PROJECT_NUMBER@gcp-sa-mediaedgefill.iam.gserviceaccount.com is the
project number of the project with the EdgeCacheService resources that need
access. You can repeat this for multiple projects, especially if some of them
house different Media CDN environments (such as development,
staging, or production) and a separate project contains your video or media
assets.
You can protect access to your Cloud Storage origin without enabling signed requests for that route.
Configuring private Cloud Storage doesn't prevent your cached content from being directly accessed from Media CDN. For information about how you can issue signed requests to individual users, see signed requests.
Configure an external Application Load Balancer as an origin
If you require active health-checking, round-robin, or load-aware steering across Compute Engine, GKE, or on-premises origins, you can configure an external Application Load Balancer as an origin.
This lets you configure (for example) your live streaming packagers behind Media CDN or a group of Envoy proxies managed by Cloud Service Mesh for connecting back to your on-premises infrastructure.
Load balancers let you configure backends for the following:
- Compute Engine virtual machine (VM) instance groups.
- Network endpoint groups (including Compute Engine VMs and Google Kubernetes Engine clusters).
- Serverless network endpoint groups (Cloud Run, App Engine, and Cloud Run functions).
An architecture that combines an external Application Load Balancer origin for serving video manifests and a Cloud Storage origin for segment storage resembles the following, with two origins mapped to different routes.
To configure an external Application Load Balancer as an origin, you need to create an origin resource with the IP address or public hostname pointing to your load balancer's forwarding rules. A public hostname (domain name) is preferred because this is required for an SSL (TLS) certificate and for modern HTTP versions (HTTP/2 and HTTP/3).
You must also confirm the following:
- Your load balancer has a route that matches the hostname used for your
EdgeCacheServiceresource or that you have configured aurlRewrite.hostRewritefor routes where your load balancer is configured as the origin. - Your load balancer has a publicly trusted SSL (TLS) certificate configured for these hostnames.
For example, if the public domain name pointed at your load balancer's
forwarding rule is origin-packager.example.com, then you need to create an
origin with the originAddress set to this name.
Console
In the Google Cloud console, go to the Media CDN page.
Click the Origins tab.
Click Create origin.
Enter a name for the origin. For example:
load-balancer-origin.Optional: Enter a description.
For the Origin address, choose Specify a FQDN or IP address.
Enter the FQDN or IP address for your Google Cloud load balancer.
Optional: Select a failover origin to try in case this origin becomes unreachable. You can update this field later.
Select retry conditions.
For Max attempts, select the maximum number of attempts to fill cache from this origin.
Optional: Specify the following timeout values:
- For Connect timeout, select the maximum duration to wait for the origin connection to be established.
- For Response timeout, select the maximum duration to allow for a response to complete.
- For Read timeout, select the maximum duration to wait between reads of a single HTTP connection or stream.
Optional: Click Add label and specify one or more key-value pairs.
Click Create origin.
gcloud
Use the gcloud edge-cache origins create command:
gcloud edge-cache origins create LB_ORIGIN \
--origin-address=LB_ADDRESS
Replace the following:
LB_ORIGIN: the name of the originLB_ADDRESS: the FQDN or IP address—for example,origin-packager.example.com
If you are using the IP address of your forwarding rule as the origin address,
or you don't have an SSL certificate attached to your load balancer, you can
set the protocol to HTTP to fall back to unencrypted connections. We recommend
that you do this only for development or testing.