Learn how to create, configure, and activate a static website hosted in an S3 bucket.
Requirements
- an S3 bucket with an ACL public-read
- your static resources (HTML, CSS, images, js, etc.)
Instructions
Step 1: Uploading website resources
In S3, 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.
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
To activate website hosting, you will have to upload a website configuration.
Example:
aws --profile user-aws s3 website s3://my-website/ --index-document index.html --error-document error.html
Or
aws --profile user-aws s3api put-bucket-website --bucket my-website --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 3: 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}.{storage_class}.cloud.ovh.us
Where storage_class
is:
- "io" if you are using a standard bucket.
- "perf" if you are using a high perf bucket.
By default, OVHcloud S3 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
For more information and tutorials, please see our other Object Storage support guides or explore the guides for other OVHcloud products and services.