For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.us.ovhcloud.com/en/storage-and-backup/object-storage/website.md.
  • English

Object Storage - Hosting a static website in an Object Storage bucket

View as Markdown

Requirements

  • An Object Storage bucket with ACL public-read
  • Your static resources (HTML, CSS, images, js, etc.)

 

Instructions

Step 1: Uploading website resources

In Object Storage, a bucket is a flat container of objects. It does not provide any hierarchical organization as the file system on your computer does. However, you can create a logical hierarchy by using object key names that imply a folder structure.

Example:

  • index.html: Object is the root of the bucket.
  • doc/page1.html: Object is in a subfolder.
Warning

NOTE:

  • HTML pages must be uploaded with text/HTML as their ContentType.
  • CSS files must be uploaded with text/css as their ContentType.
  • Make your bucket content publicly available, i.e., all resources must have ACL "public-read".

 

Step 2: Setting the website configuration for a bucket

The bucket hosting the website and its contents must be publicly accessible, i.e., with READ permission set for all users.

Example:

Using the predefined PUBLIC-READ ACL at the bucket level:

aws --profile <profile_name> s3api put-bucket-acl --bucket <bucket_name> --acl public-read

Applying the predefined PUBLIC-READ ACL on all the objects:

#!/bin/bash
declare -a output=($(aws --profile <profile_name> s3api list-objects-v2 --bucket <bucket_name> --query='Contents[].Key' | jq -r '.[]'))
for value in "${output[@]}"
do
    aws --profile <profile_name> s3api put-object-acl --bucket <bucket_name> --key "$value" --acl public-read
done

 

Step 3: Setting the website configuration for a bucket

To activate website hosting, upload a website configuration.

Example:

ws --profile <profile_name> s3 website s3://<bucket_name>/ --index-document index.html --error-document error.html

Or

aws --profile <profile_name> s3api put-bucket-website --bucket <bucket_name> --website-configuration file://website-conf.json

If you use the AWS low-level commands with website-conf.json:

{
    "IndexDocument": {
        "Suffix": "index.html"
    },
    "ErrorDocument": {
        "Key": "error.html"
    }
}

 

Step 4: Testing the endpoint

Once the website configuration has been successfully uploaded, you can test the endpoint in your web browser. The default endpoint will depend on the region of your bucket.

http://<bucket-name>.s3-website.<region>.io.cloud.ovh.us
Info

If you want to use a custom endpoint, you will have to provide your own domain name.

Warning

NOTE:

  • Make sure the region you are hosting your bucket in supports the storage class you choose. You can check the list of supported storage classes by region here.
  • By default, OVHcloud Object Storage website endpoints do not support HTTPS. To enable HTTPS, you can use OVHcloud Load Balancer to proxy your website. For more information, see the "Go further" section of this guide.

 

Go further

Browse all the Object Storage (S3™-compatible) guides.

Browse the rest of the OVHcloud US documentation for guides on our other products and services.

Learn more about Object Storage on the OVHcloud US website.

If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.

*S3 is a trademark filed by Amazon Technologies, Inc. OVHcloud's service is not sponsored by, endorsed by, or otherwise affiliated with Amazon Technologies, Inc.