Baking Clouds Ltd

Baking Clouds provide tailored IT consultancy services to small and medium-sized companies; we cover all aspects of IT without any hidden costs.

Hosting a static website on IBM COS

Maybe you are new to Storage buckets or you are thinking why do I need this? … let’s say you want to share a ‘Maintenance page’ without having a webserver, this is a great option. There are many other use cases, just visualize serverless as a trend and how much money you can save

In this new post we will explain how an IBM Cloud Storage bucket can be configured to host a static website for a domain that you own.
Static web pages can include client-side technologies including HTML, CSS , and JavaScript. They can’t handle complex content like server-side scripts such as PHP.

Before you begin you need the following to get started with IBM Cloud Object Storage:

  • An IBM Cloud® Platform account
  • An instance of IBM Cloud Object Storage
  • And the files on your local computer to upload to Object Storage.

Sign up for IBM Cloud Platform account

Before you create a new IBM Cloud Object Storage storage instance, it’s necessary to create a customer account first.

  • Go to cloud.ibm.com and click Create a Free Account.
  • Complete the form with your email address, name, region, and phone number. Choose a password.
  • Follow the link provided by the confirmation email, and follow the links to log in to the IBM Cloud® Platform.
  • Next, create a new object storage service instance!

Provisioning object storage bucket

Object Storage can be ordered completely self-service via the IBM Cloud Catalog.

Log in to your IBM Cloud Account at https://cloud.ibm.com/ and navigate to the Object Storage service tile in the IBM Cloud Catalog:

Click to provision a Standard instance of Cloud Object Storage.
This plan does not limit your amount of storage and you only pay for what you use:

A screenshot of a social media post

Description automatically generated

Navigate to the Buckets tab on the left navigation and create a Bucket to store your data

For more information about the differences between Custom vs Predefined buckets visit IBM’s website

  • Type in a unique bucket name.
  • Choose your resiliency.
  • Choose your location. This is where your data will reside. For a complete list of worldwide locations, please visit: https://www.ibm.com/cloud/object-storage/resiliency
  • Choose your storage class (all alternatives can be used for hosting the static site):
    • Standard for data with active workloads.
    • Vault for less-active workloads.
    • Cold Vault for cold workloads.
    • Flex for dynamic workloads.

Upload your files

Now you need to upload your files. There are different options to do it.
Use the GUI, API call, or compatible S3 command tool. For more details refer to IBM’s documentation

Sample of HTML file:

<h1 style="text-align: center;"><img src="https://i.imgur.com/lchn0ez.png" alt="" width="91" height="80" /> My First Website using S3 Serverless architecture</h1>
<p style="font-family: verdana;">&nbsp;</p>
<h2>VMware Cloud Director Admin</h2>
<p style="font-family: verdana;">Visit <a href="https://vmware.com target=" rel="noopener noreferrer">VMware.com </a>for all VMware Cloud Director documents</p>
<p>&nbsp;</p>

The next step is to enable the link to be accessible.

Enable Public Access to bucket files

  • Click the “Access Policies” menu item from the bucket level menu.
  • Click the “Public Access” tab from the bucket access policy page.
  • Check the Access Group drop-down has “Public Access” option selected.
  • Click the “Create access policy” and then “Enable” on the pop menu.

Access the files

The files stored in the bucket should now be accessible using the service endpoint URL, bucket id and file names.

  • Open the “Configuration” panel on the bucket page.
  • Retrieve the public endpoint shown, e.g. s3.<REGION>.cloud-object-storage.appdomain.cloud
  • Select the file hosted in the bucket, click Object Actions and select Object Details. URL path addressing will be displayed:

If Administrators want to limit access to individual buckets they can use the option of “bucket firewall”, which restricts all access to data unless the request originates from a list of allowed IP addresses. Setting Firewall

Advanced Configuration

IBM Cloud Catalog offers Cloud Internet Services Page Rules which can create custom Domain Support for COS buckets automatically.
CNAME DNS records are created to alias the custom domain to the COS bucket hostname. All traffic to the custom domain is then forwarded to the COS service. When COS serves files from bucket sub-domains, the HTTP Host request header value to determine the bucket name.

What do you need?

  • Select the Rule Behaviour Setting as “Resolve Override with COS” Select the correct COS instance and bucket.
  • Click “Create”

Once DNS records are updated, the bucket files should be accessible using the custom domain: http(s)://<CUSTOM_DOMAIN>/index.html.

For more advanced users we recommend to follow the instructions described on https://www.ibm.com/cloud/blog/static-websites-cloud-object-storage-cos which includes putting a reverse proxy, like NGINX, in front of an IBM Cloud Object Storage (COS) instance giving you the ability to use your own URL, add custom caching controls, and allow you to gather more detailed statistics about who is accessing your content.

We hope you enjoyed this post and share your experience using buckets.

Hosting a static website on IBM COS
Scroll to top