VK Cloud logo

Managing static site hosting configuration

VK Object Storage allows using a bucket for static website hosting.

Get the static website configuration

  1. Install and configure the AWS CLI, if not already installed.

  2. 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.ru or https://hb.ru-msk.vkcloud-storage.ru — the Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — the Kazakhstan region domain.

Apply a new static website configuration

  1. Install and configure the AWS CLI, if not already installed.

  2. Create a new bucket.

  3. Set the public-read ACL configuration for the bucket, if this has not been done earlier. This is required for public access to objects; otherwise, requests will fail with a 403 error.

  4. Create a new configuration file <КОНФИГУРАЦИЯ>.json.

  5. Specify the configuration of the static website in the file.

  6. 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.ru or https://hb.ru-msk.vkcloud-storage.ru — the Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — the Kazakhstan region domain.
  7. 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.ru or hb.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.

Edit the static website configuration

  1. Install and configure the AWS CLI, if not already installed.

  2. Save the configuration locally to a file <КОНФИГУРАЦИЯ>.json using the command:

    aws s3api get-bucket-website --bucket <ИМЯ_БАКЕТА> --output json --endpoint-url <ENDPOINT_URL> > <КОНФИГУРАЦИЯ>.json

    Here:

    • <ИМЯ_БАКЕТА> — 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.ru or https://hb.ru-msk.vkcloud-storage.ru — the Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — the Kazakhstan region domain.
  3. Make the necessary changes to the <КОНФИГУРАЦИЯ>.json file. If necessary, set other configuration parameters.

  4. 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.ru or https://hb.ru-msk.vkcloud-storage.ru — the Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — the Kazakhstan region domain.

Delete the static website configuration

  1. Install and configure the AWS CLI, if not already installed.

  2. 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.ru or https://hb.ru-msk.vkcloud-storage.ru — the Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — the Kazakhstan region domain.
Was this article helpful?