---
title: "CDN"
description: "Serve your sites over HTTPS from locations near your visitors, in front of one origin, with your own domains."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CDN

A distribution serves a site over HTTPS from locations near its visitors and forwards each request
to one origin: an EZGH [load balancer](/load-balancers), an instance, any server on the
internet, or a private [Object Storage](/object-storage) bucket. Each distribution has a default hostname, `d<12 characters>.ezghcdn.com`, that serves at
once. Your own domains each need a Web Certificates certificate in the same project,
and a CNAME record to the default hostname.

- [Put a site behind the CDN](/cdn/guides/put-a-site-behind-the-cdn) — Create a distribution, add your domain with its certificate, and CNAME it.
- [Serve a private bucket](/cdn/guides/serve-a-private-bucket) — Point a distribution at an Object Storage bucket without making it public.
- [Serve a single-page app](/cdn/guides/serve-a-single-page-app) — Answer an app's client-side routes with index.html, using rewrites.
- [Origins](/cdn/origins) — Where requests go, which addresses are refused, and what the origin receives.
- [/cdn-cgi/trace](/cdn/trace) — Ask any location who answered and what it saw.
- [Pricing](/cdn/pricing) — Distributions and data served are free.

The CDN API is at `https://cdn.ezghcloud.com`. In the console, open **CDN**.

## How a request is served

1. A visitor's DNS lookup of your domain follows its CNAME to the distribution's default hostname,
   which answers with the CDN's addresses. The nearest location receives the request.
2. The location ends TLS with your domain's certificate (TLS 1.2 and 1.3, HTTP/2 and HTTP/1.1).
   A hostname no distribution serves fails the TLS handshake.
3. It forwards the request to the origin and returns the answer. Nothing is cached.

On port 80, a hostname of an enabled distribution answers `301` to `https://`.

## Distributions

| Field | Meaning |
| --- | --- |
| `defaultHostname` | `d<12 characters>.ezghcdn.com`. Assigned at create, never changes, and never given to another distribution |
| `origin` | `host`, `port`, `protocol` (`https` or `http`) and `hostHeader`, or `bucket`. See [Origins](/cdn/origins) |
| `domains` | Up to 10 of your own hostnames, each with the `crt_` certificate that covers it |
| `enabled` | `false` keeps the distribution and its hostnames, and serves nothing for them (`421`) |
| `status` | `deploying` after every change until every location has it, then `deployed` |

A create answers `201` at once with `status` `deploying`. A change is a whole-document replace
([UpdateDistribution](/cdn-api/UpdateDistribution/)) with the `ETag` of your last read as
`If-Match`.

## Domains

- A hostname is exact (`www.example.com`) or a one-label wildcard (`*.example.com`). An exact
  hostname is served before a wildcard that covers it.
- Its certificate must cover it (exactly, or by a wildcard one label up), be in the same project,
  and attaching it needs `certificates.certificates.use` on it. The certificate is the proof that
  the domain is yours; there's no separate verification.
- One distribution serves a hostname at a time. A hostname another distribution serves, or one
  being removed from it, is refused with `409 conflict` until the removal finishes.
- Hostnames under `ezghcdn.com`, `ezghcloud.com` and EZGH's other domains are refused.
- Renewed certificates are picked up without a change to the distribution.

## Limits

| Limit | Value |
| --- | --- |
| Distributions per project | 20 by default, up to 200 |
| Domains per distribution | 10 |

A create over a quota is refused with [`409 quota_exceeded`](/quotas/quota-exceeded). Request an
increase on the console's **Service quotas** page.

## IAM

| Policy | Allows |
| --- | --- |
| `CdnFullAccess` | Create, change and delete distributions. |
| `CdnReadOnlyAccess` | View distributions. `ReadOnlyAccess` includes the same. |

| Action | Allows |
| --- | --- |
| `cdn.distributions.list` | List a project's distributions |
| `cdn.distributions.get` | View a distribution |
| `cdn.distributions.create` | Create distributions |
| `cdn.distributions.update` | Change a distribution |
| `cdn.distributions.delete` | Delete a distribution |

Adding a domain also needs `certificates.certificates.use` on its certificate.

## Trails

[Trails](/trails) records `CreateDistribution`, `UpdateDistribution` and `DeleteDistribution`, with
the caller and the distribution. A change that's refused is recorded too, with `errorCode`.
Individual requests to your sites are never recorded.

Source: https://docs.ezghcloud.com/cdn/index.mdx
