Static website hosting
You can host your static website in Object Storage. A static website is one that is based on such client-side technologies as HTML, CSS, or JavaScript. It may not contain any scripts that run on the web server side.
Note
To enable hosting, you need public access to the bucket. Otherwise, Object Storage will return the 403 error code to the user trying to access the website.
Object Storage allows you to configure a bucket:
-
For static website hosting.
Upload your website content to the bucket and specify the home page
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <IndexDocument> <Suffix>index.html</Suffix> </IndexDocument> <ErrorDocument> <Key>error.html</Key> </ErrorDocument> </WebsiteConfiguration>
-
To redirect all requests.
You can specify the host to which all requests will be redirected, as well as the protocol for transmitting requests
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <RedirectAllRequestsTo> <HostName>example.com</HostName> <Protocol>http</Protocol> </RedirectAllRequestsTo> </WebsiteConfiguration>
-
For conditionally redirecting requests.
Using routing rules, you can redirect requests based on the object name prefixes or HTTP response codes. You can redirect an object request to other web pages (if the object was deleted) or redirect the requests that return errors.
Example of a rule that redirects a request to a deleted folder to another page
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <RoutingRules> <RoutingRule> <Condition> <KeyPrefixEquals>temp/</KeyPrefixEquals> </Condition> <Redirect> <ReplaceKeyWith>folderdeleted.html</ReplaceKeyWith> </Redirect> </RoutingRule> </RoutingRules> </WebsiteConfiguration>
You can configure static website hosting, redirection for all requests, or conditional request redirection using the Yandex Cloud management console.
All hosting settings are available through Amazon S3-compatible HTTP API.
After you configure the bucket for hosting, the website will become accessible at:
http(s)://<bucket_name>.website.yandexcloud.net
or
http(s)://website.yandexcloud.net/<bucket name>
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
To provide HTTPS support for a bucket with a dot in the name, upload your own security certificate to Object Storage.
Request redirects from HTTP to HTTPS are enabled automatically once you set up HTTPS access to a bucket. No other settings are required.
When accessing your website, you will receive responses with the codes described in the Static website response codes section.
When hosting a website, you can:
-
To use HTTPS with your own domain, specify the FQDN of the required domain in the bucket name.
You can manage Yandex Cloud DNS domains in the bucket settings or in Cloud DNS.
You can get files from a publicly available bucket using a public link via both HTTP and HTTPS even if the bucket has no website hosting configured. In this case, a cloud-level certificate from GlobalSign