--- title: "Serve a bucket through the CDN" description: "Serve a public E2E Object Storage bucket's files, such as images and videos, through E2E CDN with Add to CDN, and find each file's CDN address." content_type: "how-to" product: "cdn" platform: "MyAccount" url: "/myaccount/cdn/how-to/serve-a-bucket-through-the-cdn/" relationships: {"requires":["/myaccount/cdn/how-to/request-cdn/","/myaccount/object-storage/how-to/make-a-bucket-public/"]} --- # Serve a bucket through the CDN **Add to CDN** on a bucket creates a distribution with the bucket as its origin, so the bucket's files, such as images, scripts, and videos, are served from edge locations near each visitor. MyAccount fills in the bucket's address for you. ## Before you begin - CDN is on for your account. If it is not yet, **Add to CDN** asks you to request it first. See [Request CDN](/myaccount/cdn/how-to/request-cdn/). - You have a bucket with your files in it, in the folder structure your site expects. See [Create a bucket](/myaccount/object-storage/how-to/create-a-bucket/) and [Upload and download objects](/myaccount/object-storage/how-to/upload-and-download-objects/). - The bucket has public access turned on, with **Download** and **Listing** checked, so that anyone can read its files. **Add to CDN** needs both. Without them, it stops with **Public Access Required**: "Your bucket \ is not public. You need to enable public access to create a CDN with this bucket." See [Make a bucket public](/myaccount/object-storage/how-to/make-a-bucket-public/). Public access opens every file in the bucket to anyone who has its address, so keep only files you mean to publish in this bucket. **Add to CDN** does not open **Select CDN plan**. For how CDN is billed, see [How is CDN billed?](/myaccount/cdn/faq/#how-is-cdn-billed). ## Add the bucket to the CDN 1. In MyAccount, open Object Storage, with the bucket's region selected, and find the bucket in the list. 2. In the bucket's **Actions** menu, choose **Add to CDN**. The form **CDN Distribution with \ as origin** opens, with your bucket's name in place of ``. 3. Check **Origin Domain Name**. It is filled in with the bucket's address for the region selected, and stays as it is: `.objectstore.e2enetworks.net` in Delhi, or `.in-south1-objectstore.e2enetworks.net` in Chennai. 4. Leave **Origin path** empty to serve the whole bucket. The bucket's name is already part of **Origin Domain Name**, so entering `/` makes the CDN look for a folder of that name inside the bucket, and your files get an HTTP 404 error. 5. (Optional) To serve only one folder of the bucket, enter it in **Origin path**, such as `/videos`. Start it with `/`; spaces cannot be typed. The field reads **Path should start with slash('/')** when the path does not start with `/`, and **Path cannot be only slash('/').** when it is only `/`. 6. Keep **Origin ID** as it is filled in. It is required, and the bucket's **Bucket CDN** tab finds the distribution by it. 7. Click **Create CDN**. To go back without creating anything, click **Cancel**. A bucket's distribution always uses **E2E SSL Certificate (\*.e2enetworks.net)**: it serves your files at its own Distribution URL. To serve files at your own domain name, the origin must be on your own domain; see [Create a distribution](/myaccount/cdn/how-to/create-a-distribution/#optional-serve-files-at-your-own-domain-name). **Bucket CDN created successfully** confirms it, and you are back in Object Storage. The bucket gets a **Bucket CDN** tab with **Distribution ID**, **Distribution Domain URL**, **Distribution State**, **Domain name**, **Distribution Status**, and **Created On (IST)**. **Add to CDN** is no longer available for this bucket. ## Close the bucket's file list Once the bucket is added to the CDN, anyone can see the names of all the files in it at the Distribution URL's root address, `https:///`, because **Add to CDN** needs **Listing** checked. To keep the names private, open the bucket's **Permissions** tab, click **Public Access Config**, clear **Listing**, keep **Download** checked, and click **Save Permission**. The root address then returns an HTTP 403 error, and your files keep loading through the CDN. Before you later delete this distribution, check **Listing** again, so that **Add to CDN** becomes available for the bucket after the delete; see [Delete a distribution](/myaccount/cdn/how-to/disable-or-delete-a-distribution/#delete-a-distribution). For a website, also set **Default Root object** to your home page, such as index.html, so the root address returns that page in place of the 403 error; see [Change the basic settings](/myaccount/cdn/how-to/change-distribution-settings/#change-the-basic-settings). If the CDN served the list before you closed it, it can keep serving that copy until you clear the cache for the path `/` with **Flush Cache** on the distribution's **Invalidations** tab, or the copy expires. See [Clear the cache](/myaccount/cdn/how-to/clear-the-cache/). ## Wait for Deployed In MyAccount, under **Network**, click **CDN**. The new distribution is on **Manage CDN Services**, with the bucket's address under **Domain Name**. It shows **InProgress** and **Disabled** while it deploys, which takes up to 30 minutes, and the page can show the change up to 15 minutes after that. When it shows **Deployed** and **Enabled**, the bucket's files are served through the CDN. ## Find a file's CDN address Copy the address under **Distribution URL**. A file's CDN address is that address followed by the file's path in the bucket. For a video at `videos/intro.mp4` in the bucket, with **Origin path** left empty, it is: ```text https:///videos/intro.mp4 ``` Here, `` is the address you copied. To check it, run: ```bash curl -I https:///videos/intro.mp4 ``` The status `200` on the first line of the output means the CDN served the file. Use the CDN address in your site's pages and video players in place of the bucket's own address. ## Manage the distribution Clearing the cache, changing settings, disabling, and deleting a bucket's distribution are all done on **Manage CDN Services**. The bucket's **Bucket CDN** tab shows the distribution's details, and has no controls of its own. - When you replace a file in the bucket, visitors keep getting the cached copy until it expires. To serve the new one sooner, see [Clear the cache](/myaccount/cdn/how-to/clear-the-cache/). - When you delete the distribution, MyAccount first warns "This CDN distribution is serving content from the bucket \." After the delete, **Add to CDN** is available for the bucket again. See [Disable or delete a distribution](/myaccount/cdn/how-to/disable-or-delete-a-distribution/). ## A bucket as the origin of Create CDN You can also enter `.objectstore.e2enetworks.net` as **Origin Domain Name** on **Create CDN**. That distribution works the same way, but the bucket gets no **Bucket CDN** tab, and **Add to CDN** stays available for it. **Add to CDN** is the simpler way, since it fills in the origin and links the distribution to the bucket. Your bucket's files are now served through the CDN. If **Add to CDN** stops you, or a file does not load, see [Troubleshooting CDN](/myaccount/cdn/troubleshooting/cdn/).