Object Storage - Hosting a static website in an Object Storage bucket
Objective
This guide explains how to create, configure and activate a static website hosted in an Object Storage bucket.
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.
- 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 permissions
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:
Applying the predefined PUBLIC-READ ACL on all the objects:
Step 3: Setting the website configuration for a bucket
To activate website hosting, upload a website configuration.
Example:
Or
If you use the AWS low-level commands with website-conf.json:
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.
If you want to use a custom endpoint, you will have to provide your own domain name. Find more information on OVHcloud domain name offers on the OVHcloud website.
- 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 regions here.
- By default, OVHcloud Object Storage website endpoints do not support HTTPS. In order 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
Enable HTTPS on a static website using a custom fqdn
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 assisting you on your specific use case of your project.
Join our community of users.