Static website in Yandex Object Storage using the management console
To host a static website in Object Storage using the Yandex Cloud management console:
- Prepare your cloud.
- Create a public bucket.
- Enable a website for a bucket.
- Configure the DNS.
- Upload the website files.
- Test the website.
If you no longer need the resources you created, delete them.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost of hosting a static website includes:
- Fee for storing data for a static website (see Object Storage pricing).
- Fee for data operations (see Object Storage pricing).
- Fee for outgoing traffic from Yandex Cloud to the internet (see Object Storage pricing).
- Fee for public DNS queries and zones (see Yandex Cloud DNS pricing).
Create a public bucket
To create a bucket for static website files:
-
In the Yandex Cloud management console
, select a folder to create a bucket in. -
On the folder page, click Create resource and select Bucket.
-
In the Name field, enter a name for the bucket. Once configured, the bucket will be available at two addresses:
http(s)://<bucket_name>.website.yandexcloud.net
http(s)://website.yandexcloud.net/<bucket_name>
The name must meet the following requirements:
- The name must be from 3 to 63 characters long.
- The name may contain lowercase Latin letters, numbers, hyphens, and periods.
- The first and last characters must be letters or numbers.
- The characters to the right and left of the period must be letters or numbers.
- The name must not look like an IP address, e.g.,
10.1.3.9
.
If you have a registered domain name (e.g.,
example.com
) and you want your website to be accessible atwww.example.com
, specifywww.example.com
as the bucket name.Note
If you plan to use your own domain for the website, the bucket name must exactly match the name of your domain, and this must be a third-level domain or higher. For more information, see Your own domain.
-
In the Object read access field, specify
Public
. -
Click Create bucket.
Enable a website for a bucket
-
Upload and configure the home page and error handling page for the future website. To do this, create the following files on your computer:
index.html
containing theHello world!
string. The file contents will be displayed when accessing the website's home page.error.html
containing theError!
string. The file contents will be displayed when the website responds with4xx
errors.
-
Upload the created files to the bucket:
Management console-
In the management console
, select the folder where the bucket is located. -
In the list of services, select Object Storage. In the window that opens, select the bucket created earlier.
-
In the left-hand panel, select Objects.
-
Click Upload. In the window that opens, select the created files and confirm the upload.
-
In the left-hand panel, select Settings.
-
On the Website tab:
- Select
Hosting
. - In the Home page field, specify
index.html
. - In the Error page field, specify
error.html
. - Click Save.
- Select
-
-
Make sure the home of your website opens. To do this, access the website from a browser at
http://<bucket_name>.website.yandexcloud.net
. -
Make sure the error page opens. To do this, access the website from a browser at
http://<bucket_name>.website.yandexcloud.net/error-check
.
Note
By default, the website is accessible only over HTTP, e.g., at http://www.example.com
or http://www.example.com.website.yandexcloud.net
. To enable HTTPS for your website, upload your own security certificate to Object Storage.
Configure the DNS
If you have a registered domain name, assign it to the bucket. To do this, create a CNAME DNS record.
You can use the Cloud DNS service to manage the domain.
Note
The bucket name must exactly match the name of your domain, and this must be a third-level domain or higher. For more information, see Your own domain.
The tutorial below describes how to configure DNS for the third-level www.example.com
domain name.
Add a zone
To create a public DNS zone:
-
In the management console
, select the folder where you want to create a public zone. -
In the list of services, select Cloud DNS.
-
Click Create zone. In the window that opens, specify the DNS zone settings:
- Zone: Specify your registered domain name, e.g.,
example.com.
. The field value must end with a dot. - Type:
Public
. - Name:
example-zone-1
.
- Zone: Specify your registered domain name, e.g.,
-
Click Create.
Add a CNAME resource record
Create a CNAME resource record in the public DNS zone:
-
In the management console
, select the folder that houses the public DNS zone. -
In the list of services, select Cloud DNS and select the DNS zone you created previously.
-
Click Create record. In the window that opens, set the record parameters:
- In the Name field, select
Create subdomain
and enter the subdomain value, e.g.,www
. - In the Type field, select
CNAME
. - In the Data field, specify the resource record value, e.g.,
www.example.com.website.yandexcloud.net
, wherewww.example.com
is the name of the public bucket created earlier.
- In the Name field, select
-
Click Create.
The subdomain name in the CNAME record must match the name of the bucket. For example, if you are creating a CNAME record named www.example.com.
, your bucket name should be www.example.com
.
Delegate the domain name
Delegation is the transfer of authority from the registrar's servers to yours. For a domain, NS resource records (ns1.yandexcloud.net
and ns2.yandexcloud.net
) are created.
To delegate a domain, specify its DNS servers in the registrar's account.
Delegation does not take effect immediately. It usually takes up to 24 hours (86,400 seconds) for internet service providers to update records. This depends on the TTL
You can check the domain delegation using Whoisdig
utility:
dig +short NS example.com
Result:
ns2.yandexcloud.net.
ns1.yandexcloud.net.
Upload the website files
After you configure and test availability, upload the remaining files that are necessary for website operation. To do this, use the management console
Test the website
To check that the website is running, use one of the standard Object Storage addresses:
http://<bucket_name>.website.yandexcloud.net
http://website.yandexcloud.net/<bucket_name>
If you configured your own domain for the website, use its address, e.g., http://www.example.com
.
How to delete the resources you created
To stop paying for the resources: