Support for multiple domain names using the management console, CLI, or API
To create an infrastructure to support multiple website domain names using the Yandex Cloud management console, CLI, or API:
- Create buckets.
- Set up a static website for your main domain.
- Set up a redirect for an additional domain.
- Check the performance of several domains.
Create buckets
Create buckets and name them according to the domain names, e.g., example.com and example2.com.
-
Create a bucket for the main
example.comdomain name:Management consoleYandex Cloud CLIAPI-
In the management console
, select the folder where you want to create a bucket. -
Go to Object Storage.
-
In the top panel, click Create bucket.
-
On the bucket creation page:
-
Enter a name for the bucket according to the main domain name of the website, e.g.,
example.com.Note
Bucket names must match domain names.
-
Set the maximum bucket size.
-
Enable
For all: Access for any users. -
Select the default storage class:
Standard. -
Click Create bucket to complete the operation.
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter.-
View the description of the CLI command to create a bucket:
yc storage bucket create --help -
Create a bucket in the default folder:
yc storage bucket create --name <bucket_name> \ --public-read \ --public-listWhere:
-
--name: Bucket name according to the main domain name of the website, e.g.,example.com.Note
Bucket names must match domain names.
-
--public-read: Enables public read access to bucket objects. -
--public-list: Enables public view access to the list of bucket objects.
Result:
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******** -
To create a bucket, use the create REST API method for the Bucket resource, the BucketService/Create gRPC API call, or the create S3 API method.
-
-
Create a bucket for the additional
example2.comdomain name by repeating the steps above.
Set up a static website for your main domain
Set up a static website for the bucket and link it to your main example.com domain name:
-
Set up the
example.combucket to host your static website.Management consoleYandex Cloud CLIAPI- In the management console
, select a folder. - Go to Object Storage.
- Select the bucket you want to configure hosting for.
- In the left-hand panel, select
Settings. - Select the Website tab.
- 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.Warning
The key of the object containing your website homepage must not include the
/character. -
Optionally, in the Error page field, specify the absolute path to the file in the bucket to show for
4xxerrors, e.g.,pages/error404.html. By default, Object Storage returns its own page.
-
- Click Save.
Use the link in Link to check the hosting.
-
See the description of the CLI command for setting up static website hosting in a bucket:
yc storage bucket update --help -
Create a hosting configuration file in JSON format. Here is an example:
{ "index": "index.html", "error": "error404.html" }Where:
-
index: Absolute path to the website home page file.Warning
The key of the object containing your website homepage must not include the
/character. -
error: Absolute path to the file the user will see in case of4xxerrors.
-
-
Run this command:
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:
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:
yc storage --name <bucket_name> bucket get --fullResult:
website_settings: index: index.html error: error404.html redirect_all_requests: {}To set up hosting for a static website, use the update REST API method for the Bucket resource, the BucketService/Update gRPC API call, or the upload S3 API method.
- In the management console
-
Link the
example.comdomain name and the relevant bucket.-
On the DNS sever, create a public DNS zone and a resource record which links your domain name to the bucket:
Yandex Cloud DNSThird-party DNS serverWarning
Cloud DNS usage is chargeable; for more information, see Cloud DNS pricing policy.
-
In the management console
, select a folder. -
Go to Object Storage.
-
Select the bucket you want to use your own domain for.
-
In the left-hand panel, select
Settings and go to the Website tab. -
In Hosting, under Domains in Cloud DNS, click Create record.
Note
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 will not be shown.
-
In the window that opens, click Create zone and select the domain zone that matches the bucket name, e.g.,
example.com. Click Create. -
Expand Additional settings.
-
In the TTL (in seconds) field, specify the resource record time to live or select a value from the list.
-
Click Create.
-
Click Save.
To gain access to public zone domain names, delegate the domain by specifying the
ns1.yandexcloud.netandns2.yandexcloud.netserver 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 and resource record.
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 records enable using second-level domains for hosting. Unlike CNAME records, they do not restrict the use of other record types in the same zone.
Here is an example of DNS zone parameters:
- Zone:
example.com - Type:
Public
An example of a CNAME resource record looks like this:
example.com CNAME example.com.website.yandexcloud.netTo 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
, section 2.4.Updating resource records may take a while.
As a result, the static website will be available at
example.com. -
-
-
Configure HTTPS by linking a Certificate Manager certificate to your bucket or uploading your own.
Note
You can use one certificate for both your main and additional domains or multiple certificates for each domain.
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
For the bucket with the additional example2.com domain name:
-
Set up the
example2.combucket to redirect all requests to the mainexample.comdomain and use HTTPS.Management consoleYandex Cloud CLIAPI- In the management console
, select a folder. - Go to Object Storage.
- Select the bucket you want to redirect all requests for.
- In the left-hand panel, select
Settings. - Select the Website tab.
- Under Redirect, specify:
- Domain name: Domain name to which all requests will be redirected, e.g.,
example.com. - Protocol: HTTPS.
- Domain name: Domain name to which all requests will be redirected, e.g.,
- Click Save.
-
See the description of the CLI command for setting up redirects for all requests:
yc storage bucket update --help -
Create a redirect configuration file in JSON format. Here is an example:
{ "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.
-
Run this command:
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:
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"
To set up redirects for all requests to a bucket, use the update REST API method for the Bucket resource, the BucketService/Update gRPC API call, or the upload S3 API method.
- In the management console
-
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.
-
Link the
example2.comdomain name and the relevant bucket.
Check the performance of several domains
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.