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 environment.
- Create a public bucket.
- Enable a website for a bucket.
- Configure DNS.
- Upload the website files.
- Test the website.
If you no longer need the resources you created, delete them.
Prepare your cloud environment
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, specify the bucket name. 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 atexample.com
, specifyexample.com
as the bucket name.Note
If you plan to use your own domain for the website, the bucket name must be an exact match of your domain name. Use a second-level domain or higher. For more information, see Custom 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 the textHello world!
. The file contents will be displayed on the website's home page.error.html
containing the textError!
. 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:
- Go to the
Website
tab and selectHosting
. - In the Home page field, specify
index.html
. - In the Error page field, specify
error.html
. - Click Save.
- Go to the
-
-
Make sure your website's home page 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
.
By default, the website is accessible only over HTTP, e.g., at http://example.com.website.yandexcloud.net
. To provide HTTPS support for your website:
-
Add your own security certificate or a Let's Encrypt certificate in Yandex Certificate Manager.
-
Configure HTTPS support for your bucket. Your website will then be accessible over HTTPS at
https://example.com.website.yandexcloud.net
.Note
When using a URL in
http(s)://<bucket_name>.storage.yandexcloud.net
format, the HTTPS protocol is available for the bucket only if the bucket name does not contain dots. For example:https://example.storage.yandexcloud.net
HTTPS is available for this bucket.http://example.ru.storage.yandexcloud.net
HTTPS is not available for this bucket.
This is because Object Storage uses Wildcard certificates
, which only support one level of subdomains.To provide HTTPS support for a bucket with a dot in the name, upload your own security certificate to Object Storage.
-
For access by the short domain name (
example.com
), configure DNS.
Configure DNS
If you have a registered domain name, assign it to the bucket. To do this, create an ANAME DNS record.
You can use Cloud DNS to manage the domain.
Note
The bucket name must be an exact match of your domain name. Use a second-level domain or higher. For more information, see Custom domain.
The tutorial below describes how to set up DNS for an example.com
second-level domain.
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 an ANAME resource record
Create an ANAME 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 earlier.
-
Click Create record. In the window that opens, set the record parameters:
- In the Name field, select
Create subdomain
and enter the domain value, e.g.,example.com
. - In the Type field, select
ANAME
. - In the Data field, specify the resource record value, e.g.,
example.com.website.yandexcloud.net
, whereexample.com
is the name of the public bucket created earlier.
- In the Name field, select
-
Click Create.
The domain name in the ANAME record must match the name of the bucket. For example, if you are creating an ANAME record named example.com
, your bucket name should be 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 have configured your own domain for a website, use its address, e.g., example.com
.
How to delete the resources you created
To stop paying for the resources: