[Yandex Cloud documentation](../../../../index.md) > [Yandex Object Storage](../../../index.md) > [Step-by-step guides](../../index.md) > Hosting static websites > [Support for multiple domain names](index.md) > Management console, CLI, and API

# Support for multiple domain names using the management console, CLI, or API

To create an infrastructure to support [multiple website domain names](index.md) using the Yandex Cloud management console, CLI, or API:
1. [Create buckets](#buckets).
1. [Set up a static website for your main domain](#common).
1. [Set up a redirect for an additional domain](#xtra).
1. [Check the performance of several domains](#test).


## Create buckets {#buckets}

Create buckets and name them according to the domain names, e.g., `example.com` and `example2.com`.

1. Create a bucket for the main `example.com` domain name:

    {% list tabs group=instructions %}

    - Management console {#console}

      1. In the [management console](https://console.yandex.cloud), select the folder where you want to create a bucket.
      1. Navigate to **Object Storage**.
      1. In the top panel, click **Create bucket**.
      1. On the bucket creation page:

          1. Enter a name for the bucket according to the main domain name of the website, e.g., `example.com`.

              {% note info %}

              Bucket names must match domain names. 

              {% endnote %}

          1. Set the maximum bucket size.

          1. Enable `For all`: Access for any users.

          1. Select the default [storage class](../../../concepts/storage-class.md): `Standard`.

          1. Click **Create bucket** to complete the operation.

    - Yandex Cloud CLI {#cli}

      If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../../cli/quickstart.md#install).

      The folder used by default is the one specified when [creating](../../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

      1. See the description of the CLI command for creating a bucket:

          ```bash
          yc storage bucket create --help
          ```

      1. Create a bucket in the default folder:

          ```bash
          yc storage bucket create --name <bucket_name> \
            --public-read \
            --public-list
          ```

          Where: 
          * `--name`: Bucket name according to the main domain name of the website, e.g., `example.com`.

              {% note info %}

              Bucket names must match domain names. 

              {% endnote %}

          * `--public-read`: Enables public read access to bucket objects.
          * `--public-list`: Enables public view access to the list of bucket objects.

          Result:

          ```text
          name: example.com
          folder_id: b1geoelk7fld********
          anonymous_access_flags:
            read: true
            list: true
          default_storage_class: STANDARD
          versioning: VERSIONING_DISABLED
          created_at: "2025-08-08T09:12:45.743187Z"
          resource_id: e3etgi7l43gs********
          ```

    - API {#api}

      To create a bucket, use the [create](../../../api-ref/Bucket/create.md) REST API method for the [Bucket](../../../api-ref/Bucket/index.md) resource, the [BucketService/Create](../../../api-ref/grpc/Bucket/create.md) gRPC API call, or the [create](../../../s3/api-ref/bucket/create.md) S3 API method.

    {% endlist %}

1. Create a bucket for the additional `example2.com` domain name by repeating the steps above.

## Set up a static website for your main domain {#common}

Set up a static website for the bucket and link it to your main `example.com` domain name:

1. Set up the `example.com` bucket to host your static website.

    {% list tabs group=instructions %}

    - Management console {#console}

      1. In the [management console](https://console.yandex.cloud), select a folder.
      1. Navigate to **Object Storage**.
      1. Select the bucket you want to configure hosting for.
      1. In the left-hand panel, select ![image](../../../../_assets/console-icons/wrench.svg) **Settings**.
      1. Select the **Website** tab.
      1. Under **Hosting**:
          * In the **Home page** field, specify the absolute path to the file in the bucket for the website home page, e.g., `index.html`.
      
            {% note warning %}
            
            The [key of the object](../../../concepts/object.md#key) containing your website homepage must not include the `/` character.
            
            {% endnote %}
      
          * Optionally, in the **Error page** field, specify the absolute path to the file in the bucket to show for `4xx` errors, e.g., `pages/error404.html`. By default, Object Storage returns its own page.
      1. Click **Save**.

      Use the link in **Link** to check the hosting.

    - Yandex Cloud CLI {#cli}

      1. See the description of the CLI command for setting up static website hosting in a bucket:
      
          ```bash
          yc storage bucket update --help
          ```
          
      1. Create a hosting configuration file in JSON format. Here is an example:
          
          ```json
          {
            "index": "index.html",
            "error": "error404.html"
          }
          ```
      
          Where:
      
          * `index`: Absolute path to the website home page file.
      
            {% note warning %}
            
            The [key of the object](../../../concepts/object.md#key) containing your website homepage must not include the `/` character.
            
            {% endnote %}
      
          * `error`: Absolute path to the file the user will see in case of `4xx` errors.
      
            {% note tip %}
            
            If a bucket contains a [single-page application](https://en.wikipedia.org/wiki/Single-page_application), specify the home page, e.g., `index.html`, as the error page.
            
            {% endnote %}
      
      1. Run this command:
      
          ```bash
          yc storage bucket update --name <bucket_name> \
            --website-settings-from-file <path_to_file>
          ```
          
          Where:
          * `--name`: Bucket name.
          * `--website-settings-from-file`: Path to the hosting configuration file.
      
          Result:
      
          ```text
          name: my-bucket
          folder_id: b1gjs8dck8bv********
          default_storage_class: STANDARD
          versioning: VERSIONING_SUSPENDED
          max_size: "10737418240"
          acl: {}
          created_at: "2022-12-14T08:42:16.273717Z"
          ```
      
      To make sure the bucket description now contains the hosting settings, run this command:
      
      ```bash
      yc storage --name <bucket_name> bucket get --full
      ```
      
      Result:
      
      ```text
      website_settings:
        index: index.html
        error: error404.html
        redirect_all_requests: {}
      ```

    - API {#api}

      To set up hosting for a static website, use the [update](../../../api-ref/Bucket/update.md) REST API method for the [Bucket](../../../api-ref/Bucket/index.md) resource, the [BucketService/Update](../../../api-ref/grpc/Bucket/update.md) gRPC API call, or the [upload](../../../s3/api-ref/hosting/upload.md) S3 API method.

    {% endlist %}

1. Link the `example.com` domain name and the relevant bucket.

    1. On the DNS sever, create a public DNS zone and a resource record which links your domain name to the bucket:

        {% list tabs group=instructions %}

        - Yandex Cloud DNS {#dns}

          {% note warning %}

          Cloud DNS usage is chargeable; for more information, see [Cloud DNS pricing policy](../../../../dns/pricing.md).

          {% endnote %}

          1. In the [management console](https://console.yandex.cloud), select a folder.
          1. Navigate to **Object Storage**.
          1. Select the bucket you want to use your own domain for.
          1. In the left-hand panel, select ![image](../../../../_assets/console-icons/wrench.svg) **Settings** and go to the **Website** tab.
          1. In **Hosting**, under **Domains in Cloud DNS**, click **Create record**.

              {% note info %}

              Under **Domains in Cloud DNS** in the **Hosting** section, you can only see those domains that were created directly through this interface. Records created in [Cloud DNS](../../../../dns/quickstart.md) will not be shown.

              {% endnote %}

          1. In the window that opens, click **Create zone** and select the domain zone that matches the bucket name, e.g., `example.com`. Click **Create**.
          1. Expand **Additional settings**.
          1. In the **TTL (in seconds)** field, specify the resource record time to live or select a value from the list.
          1. Click **Create**.
          1. Click **Save**.
          
          To gain access to public zone domain names, delegate the domain by specifying the `ns1.yandexcloud.net` and `ns2.yandexcloud.net` server addresses in your domain registrar account.

          Delegating a domain and updating resource records may take a while.

          You can also use Cloud DNS to create a [DNS zone](../../../../dns/operations/zone-create-public.md) and [resource record](../../../../dns/operations/resource-record-create.md).
          
          {% cut "Example of DNS zone and resource record parameters" %}

          DNS zone parameters:
          * Zone: `example.com`
          * Type: `Public`

          Resource record parameters:

          | Name          | Type   | TTL | Value                      |
          |--------------|-------|-----|-------------------------------|
          | example.com. | ANAME | 600 | example.com.website.yandexcloud.net |

          [ANAME](../../../../dns/concepts/resource-record.md#aname) records enable using second-level domains for hosting. Unlike [CNAME](../../../../dns/concepts/resource-record.md#cname) records, they do not restrict the use of other record types in the same zone. 

          {% endcut %}

        - Third-party DNS server {#third-party-dns-server}

          Here is an example of DNS zone parameters:
          * Zone: `example.com`
          * Type: `Public`
          
          An example of a [CNAME](../../../../dns/concepts/resource-record.md#cname) resource record looks like this: 

          ```text
          example.com CNAME example.com.website.yandexcloud.net
          ```

          To use a CNAME resource record, make sure your domain name belongs to at least a third-level domain. This restriction is due to the way CNAME records are handled on DNS hosting platforms. For more information, see [RFC 1912](https://www.ietf.org/rfc/rfc1912.txt), section 2.4.

          Updating resource records may take a while.

        {% endlist %}

        As a result, the static website will be available at `example.com`.

1. Configure HTTPS by linking a Certificate Manager certificate to your bucket or uploading your own.

    {% note info %}

    You can use one certificate for both your main and additional domains or multiple certificates for each domain.

    {% endnote %}

    Request redirects from HTTP to HTTPS are enabled automatically once you set up HTTPS access to a bucket. No other settings are required.

As a result, the static website will be available at `example.com` using HTTPS.


## Set up a redirect for an additional domain {#extra}

For the bucket with the additional `example2.com` domain name:

1. Set up the `example2.com` bucket to redirect all requests to the main `example.com` domain and use HTTPS.

    {% list tabs group=instructions %}

    - Management console {#console}

      1. In the [management console](https://console.yandex.cloud), select a folder.
      1. Navigate to **Object Storage**.
      1. Select the bucket you want to redirect all requests for.
      1. In the left-hand panel, select ![image](../../../../_assets/console-icons/wrench.svg) **Settings**.
      1. Select the **Website** tab.
      1. Under **Redirect**, specify:
          * **Domain name**: Domain name to which all requests will be redirected, e.g., `example.com`.
          * **Protocol**: **HTTPS**.
      1. Click **Save**.

    - Yandex Cloud CLI {#cli}

      1. See the description of the CLI command for setting up redirects for all requests:

          ```bash
          yc storage bucket update --help
          ```
     
      1. Create a redirect configuration file in JSON format. For example:
     
          ```json
          {
            "redirectAllRequests": {
              "protocol": "PROTOCOL_HTTPS",
              "hostname": "example.com"
            }
          }
          ```

          Where:
          * `protocol`: Data transfer protocol.
          * `hostname`: Domain name of the host to act as the redirect target for all requests to the current bucket.

      1. Run this command:

          ```bash
          yc storage bucket update --name <bucket_name> \
            --website-settings-from-file <path_to_file>
          ```

          Where:
          * `--name`: Bucket name.
          * `--website-settings-from-file`: Path to the redirect configuration file.

          Result:

          ```text
          name: example2.com
          folder_id: b1gjs8dck8bv********
          default_storage_class: STANDARD
          versioning: VERSIONING_SUSPENDED
          max_size: "10737418240"
          acl: {}
          created_at: "2022-12-14T08:42:16.273717Z"
          ```

    - API {#api}

      To set up redirects for all requests to a bucket, use the [update](../../../api-ref/Bucket/update.md) REST API method for the [Bucket](../../../api-ref/Bucket/index.md) resource, the [BucketService/Update](../../../api-ref/grpc/Bucket/update.md) gRPC API call, or the [upload](../../../s3/api-ref/hosting/upload.md) S3 API method.

    {% endlist %}

1. Configure HTTPS by linking a Certificate Manager certificate to your bucket or uploading your own.

    Request redirects from HTTP to HTTPS are enabled automatically once you set up HTTPS access to a bucket. No other settings are required.

1. [Link](../own-domain.md) the `example2.com` domain name and the relevant bucket.


## Check the performance of several domains {#test}

Wait until the TLS certificate is issued and switches to the `Issued` status. After that, make sure the redirect works: opening the `https://example2.com` website should take you to `https://example.com`.


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

* [Support for multiple domain names using Terraform](terraform.md)