A distribution’s origin can be an Object Storage bucket in the same organization. The bucket stays private: only the distributions listed in its settings read it, and its S3 URLs still need a key.
-
Create the distribution with the bucket’s name as its origin. In the console, choose Object Storage bucket under Origin. With the CLI:
ezgh cdn distributions create --name assets --origin-bucket acme-assetsNote its ID (
cdn_…) and its default hostname, such asd4k2m9x0a7qpe.ezghcdn.com. -
Let the distribution read the bucket. In the console, open the bucket, select Permissions and add the distribution’s ID under CDN distributions. With the CLI:
ezgh objects buckets settings bkt_4k2m9x0a7qpe --cdn-distribution cdn_k2m9x0a7qpe4This needs
objects.buckets.update.--cdn-distributionreplaces the list: repeat it to keep distributions already there. -
Wait for the distribution’s
statusto bedeployed, then read an object by its key:curl https://d4k2m9x0a7qpe.ezghcdn.com/images/logo.png
To serve it on your own domain, add the domain as for any distribution: see Put a site behind the CDN.
What is served
| Request | Answer |
|---|---|
GET or HEAD of an object’s key, with Range and conditional headers |
The object |
| A key that doesn’t exist | 404 |
/, or any listing |
403 |
| Any other method | 403 |
| An object encrypted with a customer key | 403 |
| Any request while the bucket doesn’t list the distribution | 403 |
- A path is the object’s key:
/images/logo.pngreadsimages/logo.png. There is no index document: to answer/or an app’s routes withindex.html, add a rewrite, as in Serve a single-page app. - The bucket and the distribution must be in the same organization. They can be in different projects.
- A bucket lists up to 10 distributions. Whether a listed distribution exists isn’t checked.
- A bucket whose name contains a dot can’t be an origin.
- Removing a distribution from the bucket’s list applies to the next request.
- Requests through a distribution count toward the organization’s Object Storage request limit.
With the API
Create or replace the distribution with origin set to the bucket alone
(CreateDistribution):
{ "name": "assets", "origin": { "bucket": "acme-assets" } }The answer’s origin has bucket and the bucket’s host, port, protocol and hostHeader.
A replace sends { "bucket": … } again, not those four fields.
List the distribution in the bucket’s settings (UpdateBucketSettings):
{ "publicRead": false, "corsRules": [], "cdnDistributions": ["cdn_k2m9x0a7qpe4"] }Left out of the document, cdnDistributions stays as it is.