Static website hosting
You can host your static website in Object Storage. A static website is based on client-side technology such as HTML, CSS, and 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 returns a 403 error code to the user trying to access the website.
Object Storage lets you configure a bucket:
-
For static website hosting.
Upload to the bucket the content of your site and specify the main page of the site<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, and also specify 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 remote 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 the hosting settings are available through the Amazon S3-compatible HTTP API.
After you configure the bucket for hosting, the website becomes accessible at:
http(s)://<bucket_name>.website.yandexcloud.net
or
http(s)://website.yandexcloud.net/<bucket_name>
Note
By default, a bucket with a dot in the name is only available over HTTP. To grant it HTTPS support, upload your own security certificate to Object Storage.
When accessing the website, you get responses with the codes described in Static website response codes.
When hosting a website, you can: