Managing static site hosting configuration
VK Object Storage allows using a bucket for static website hosting.
-
Install and configure the AWS CLI, if not already installed.
-
Get the configuration using the command:
aws s3api get-bucket-website --bucket <ИМЯ_БАКЕТА> --endpoint-url <ENDPOINT_URL>Here:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which to get the static website configuration. -
<ENDPOINT_URL>— must match the account region:https://hb.vkcloud-storage.ruorhttps://hb.ru-msk.vkcloud-storage.ru— the Moscow region domain;https://hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-
-
Install and configure the AWS CLI, if not already installed.
-
Create a new bucket.
-
Set the
public-readACL configuration for the bucket, if this has not been done earlier. This is required for public access to objects; otherwise, requests will fail with a403error. -
Create a new configuration file
<КОНФИГУРАЦИЯ>.json. -
Specify the configuration of the static website in the file.
-
Upload the new configuration using the command:
aws s3api put-bucket-website --bucket <ИМЯ_БАКЕТА> --website-configuration file://<КОНФИГУРАЦИЯ>.json --endpoint-url <ENDPOINT_URL>Here:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which to apply the static website configuration. -
<КОНФИГУРАЦИЯ>— the name of the static website configuration file in JSON format. -
<ENDPOINT_URL>— must match the account region:https://hb.vkcloud-storage.ruorhttps://hb.ru-msk.vkcloud-storage.ru— the Moscow region domain;https://hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-
-
Go to the static website page:
https://<ИМЯ_БАКЕТА>.hb-website.<ENDPOINT_HOSTNAME>/<PREFIX>Here:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which the static website configuration was applied; -
<ENDPOINT_HOSTNAME>— the hostname of the VK Object Storage service, must match the account region:hb.vkcloud-storage.ruorhb.ru-msk.vkcloud-storage.ru— the Moscow region domain;hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-
<PREFIX>— the key prefix of the index page object. May be empty.
-
-
Install and configure the AWS CLI, if not already installed.
-
Save the configuration locally to a file
<КОНФИГУРАЦИЯ>.jsonusing the command:aws s3api get-bucket-website --bucket <ИМЯ_БАКЕТА> --output json --endpoint-url <ENDPOINT_URL> > <КОНФИГУРАЦИЯ>.jsonHere:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which to edit the static website configuration. -
<КОНФИГУРАЦИЯ>— the name of the static website configuration file in JSON format. -
<ENDPOINT_URL>— must match the account region:https://hb.vkcloud-storage.ruorhttps://hb.ru-msk.vkcloud-storage.ru— the Moscow region domain;https://hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-
-
Make the necessary changes to the
<КОНФИГУРАЦИЯ>.jsonfile. If necessary, set other configuration parameters. -
Apply the new configuration:
aws s3api put-bucket-website --bucket <ИМЯ_БАКЕТА> --website-configuration file://<КОНФИГУРАЦИЯ>.json --endpoint-url <ENDPOINT_URL>Here:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which to apply the static website configuration. -
<КОНФИГУРАЦИЯ>— the name of the static website configuration file in JSON format. -
<ENDPOINT_URL>— must match the account region:https://hb.vkcloud-storage.ruorhttps://hb.ru-msk.vkcloud-storage.ru— the Moscow region domain;https://hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-
-
Install and configure the AWS CLI, if not already installed.
-
Delete the configuration using the command:
aws s3api delete-bucket-website --bucket <ИМЯ_БАКЕТА> --endpoint-url <ENDPOINT_URL>Here:
-
<ИМЯ_БАКЕТА>— the name of the bucket for which to delete the static website configuration. -
<ENDPOINT_URL>— must match the account region:https://hb.vkcloud-storage.ruorhttps://hb.ru-msk.vkcloud-storage.ru— the Moscow region domain;https://hb.kz-ast.vkcloud-storage.ru— the Kazakhstan region domain.
-