[Yandex Cloud documentation](../../index.md) > [Yandex Cloud CDN](../index.md) > [Getting started](index.md) > Creating a CDN resource with an origin server

# Creating a CDN resource with an origin server in Yandex Cloud



{% note warning %}

Starting July 1, 2026, a new pricing model for Cloud CDN is in effect. For more information, see [Yandex Cloud CDN pricing policy](../pricing.md).

{% endnote %}


{% note info %}

For details on creating an origin group and a CDN resource with other origin types, see these guides:
  
* [Creating a resource](../operations/resources/create-resource.md)
* [Creating an origin group](../operations/origin-groups/create-group.md)

{% endnote %}

Set up content distribution over a CDN with a Yandex Compute Cloud [VM instance](../../compute/concepts/vm.md) or Yandex BareMetal [server](../../baremetal/concepts/servers.md) as the origin:

1. [Create a web server](#create-server).
1. [Create a CDN resource](#create-cdn-resource).
1. [Configure a CNAME for your domain](#setup-cname).
1. [Test the CDN](#check-cdn-working).

## Getting started {#before-you-begin}

1. Make sure you have a domain name and can access the DNS settings on your DNS hosting provider’s website. This is usually the company that registered your domain.
1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud, or sign up if you have not already.
1. If you do not have a folder yet, [create](../../resource-manager/operations/folder/create.md) one.

    {% cut "Learn more about creating a folder" %}

    1. In the [management console](https://console.yandex.cloud), in the top panel, click ![image](../../_assets/console-icons/layout-side-content-left.svg) or ![image](../../_assets/console-icons/chevron-down.svg) and select the [cloud](../../resource-manager/concepts/resources-hierarchy.md#cloud).
    1. To the right of the cloud name, click ![image](../../_assets/console-icons/ellipsis.svg).
    1. Select ![image](../../_assets/console-icons/plus.svg) **Create folder**.
    
       ![create-folder1](../../_assets/resource-manager/create-folder-1.png)
    
    1. Give your [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) a name. The naming requirements are as follows:
    
        * Length: between 3 and 63 characters.
        * It can only contain lowercase Latin letters, numbers, and hyphens.
        * It must start with a letter and cannot end with a hyphen.
    
    1. Optionally, specify the description for your folder.
    1. Select **Create a default network**. This will create a [network](../../vpc/concepts/network.md#network) with subnets in each availability zone. Within this network, you will also have a [default security group](../../vpc/concepts/security-groups.md#default-security-group), within which all network traffic will be allowed.
    1. Click **Create**.
    
       ![create-folder2](../../_assets/resource-manager/create-folder-2.png)

    {% endcut %}

## Create a web server {#create-server}

If you do not have a web server yet:

1. [Create](../../compute/operations/vm-create/create-linux-vm.md) a Compute Cloud instance or [rent](../../baremetal/operations/servers/server-lease.md) a BareMetal server.
1. Install a web server on the new server or VM instance, e.g., [Apache](https://httpd.apache.org/) or [nginx](https://nginx.org/).

    When installing the web server on a VM instance, remember to associate it with a [security group](../../vpc/concepts/security-groups.md) that allows incoming and outgoing network traffic on the appropriate ports, e.g., `80` and `443`. For more information, see [Creating a security group](../../vpc/operations/security-group-create.md).
1. Upload content to your web server.
1. Make sure your web server is available from the internet.

    To check the availability of a web server created on a Compute Cloud VM instance or BareMetal server, enter the [public IP address](../../vpc/concepts/address.md#public-addresses) of the instance or server in the address bar, for example:

    ```text
    http://198.51.100.27/
    ```

    As a result, you should see the main page of the application deployed on the server in your browser window.

Learn more about creating a website based on a Compute Cloud VM instance [here](../../tutorials/web/lamp-lemp/index.md).

## Create a CDN resource {#create-cdn-resource}

<iframe width="640" height="360" src="https://runtime.strm.yandex.ru/player/video/vplva6365yoayxar6ore?autoplay=0&mute=0" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" frameborder="0" scrolling="no"></iframe>

1. Navigate to **Cloud CDN**.
1. In the ![image](../../_assets/console-icons/nodes-right.svg) **CDN resources** tab, click **Create resource**.
1. Under **Main settings**, configure the basic CDN resource settings:
    * Under **Content**:
        * Enable **Enable access to content**.
        * In the **Content query** field, select `From one origin`.
        * In the **Origin type** field, select `Server`.
        * In the **Origin domain name** field, specify the [public IP address](../../vpc/concepts/address.md#public-addresses) of your VM instance or BareMetal server with a web server.
        * In the **Origin request protocol** field, select `HTTP`.
        * In the **Domain name** field, specify the primary domain name you will use in your website links to CDN-hosted content, e.g., `cdn.example.com`.

            {% note alert %}

            You cannot change the primary domain name used for content distribution after creating a CDN resource.

            {% endnote %}

    * Under **Additional settings**:
        * In the **Redirect clients** field, select `Don't use`.
        * In the **Certificate type** field, select `Don't use`.
        * In the **Host header** field, select `Primary domain name`.

            The **Host header** field value must match the name of the virtual host configured on the origin server.

1. Click **Continue**.
1. Under **Caching**, **HTTP headers and methods**, and **Advanced**, leave the default settings, then click **Continue**. You can configure these settings later, if required.
   
Wait until the resource is created. It may take up to 15 minutes.

{% note tip %}

We recommend [prefetching](../operations/resources/prefetch-files.md) large files (over 200 MB) into the CDN server [cache](../concepts/caching.md). This is an optional step. If skipped, such content will be automatically cached on [CDN servers](../concepts/points-of-presence.md) when first accessed by the end user.

{% endnote %}

## Configure a CNAME for your domain {#setup-cname}

1. In the ![image](../../_assets/console-icons/flag.svg) **Overview** tab on the CDN resource page, under **DNS settings**, copy the generated domain name in `e1b83ae3********.topology.gslb.yccdn.ru` format.
1. Navigate to your domain’s DNS settings on your DNS hosting provider’s website.
1. Edit the relevant CNAME record so that it points to the previously copied URL in the `.topology.gslb.yccdn.ru` domain. For example, if the content delivery domain name you specified when creating your CDN resource is `cdn.example.com`, you need to create the following CNAME record or use it to replace the current record for `cdn`:

    ```http
    cdn CNAME e1b83ae3********.topology.gslb.yccdn.ru.
    ```

    {% note info %}
    
    Do not use an [ANAME](../../dns/concepts/resource-record.md#aname) resource record with domain names for content distribution; otherwise, the end user will get a response from a CDN server not linked to the user geolocation. The response will always be the same for all users.
    
    {% endnote %}

## Test the CDN {#check-cdn-working}

1. Wait for the DNS records to update. This may take a few hours.
1. Make sure the `cdn` CNAME record in the DNS server's cache points to the generated URL, e.g., `e1b83ae3********.topology.gslb.yccdn.ru`.
1. Open the website in your browser to make sure it is working. Here is an example:

    ```http
    http://cdn.example.com/index.html
    ```

#### Useful links {#see-also}

* [Creating a CDN resource with an Yandex Object Storage origin bucket](bucket.md)
* [Yandex Cloud CDN overview](../concepts/index.md)
* [Creating a VM from a public Linux image](../../compute/operations/vm-create/create-linux-vm.md)
* [Renting a stock-configuration BareMetal server](../../baremetal/operations/servers/server-lease.md)
* [Creating a website on the LAMP or LEMP stack](../../tutorials/web/lamp-lemp/index.md)
* [Configuring a web server](../tutorials/protected-access-to-content/console.md#setup-web-server)
* [Webinar: Reducing load on high-traffic infrastructure with Cloud CDN](https://yandex.cloud/ru/events/1489?utm_source=docs&utm_medium=yandex&utm_campaign=infra&utm_content=vebinar&utm_term=cdns3)