Static Website : Hosting website on Objects .

Anirudha | Mon, 08/31/2020 - 12:54

With Objects 2.1 Nutanix introduced the feature - “Static Website” which lets you host your entire website in Objects cluster. Yes, that's right, you don't need apache/http server to host your website, Objects can help to host thousands of websites out of box.

In this article we will take a close look at this feature and we will go over a couple of use cases and we will also try to build some real world applications which can run out of Objects cluster without need of any special software.

What you need : 

  • Objects 2.2 cluster
  • Access to Objects UI.

      

This is my PrismCentral which is hosting 4 Objects instances. We are going to use “DevTest” instance for further experiments.


To Enable Static Website on Bucket :

  • Login to Nutanix Prism Central UI 
  • Navigate Objects UI 
  • Open Objects Instance Page 
  • Create Bucket (You can create bucket using API or any S3 client)
  • Select Bucket -> Actions -> Enable Static Website.
  • Provide a path to Index doc and Error doc optionally.

Use case 1

Host regular website on Objects cluster:

 I am going to try hosting a similar webpage to https://scalcia.com/blog/introducing-nutanix-objects-s3-compatible-storage  on Objects directly.

            

 

In the above Video we created a bucket, shared it with an IAM user and uploaded index.html from Cyberduck. And also made sure that no one gets access to this file .
During the configuration we gave index.html as Index Doc, which just means, when you access this website, this file will get executed on the client side. UI also gives the option to upload Error Doc which can be used to return any error encountered.

And just like that, we hosted a static website and were able to browse it right from your Objects cluster.

 

UserCase : 2 -

Last time we looked at sharing data with IAM or anonymous users @ here . Both of these methods needs either user should have access to Objects cluster Or need bit of code/third-party client to generate pre-authenticated URL. None of these solutions could provide direct access to files uploaded to the bucket to non-Objects users. And this is  we are going to cover .

In the previous experiment, we enabled “Static Website’ on “demo” bucket. While this feature helps to you host website, it can also let you download any content uploaded in bucket using wget (or any regular linux command), without need of providing any credentials.


Once you upload the file to bucket, its URL will be : http://demo.devtest.scalcia.com/file-name
 

    

I have uploaded the Static_website_demo.mov file via Cyberduck in the same bucket.

Lets try downloading it from linux host :

    

Here you can use http or https URL.  In case you have uploaded CA certs to your objects cluster, you may not need to supply --no-check-certificate flag to wget. You could use pretty much any client which can let you download file from webserver.

Next Read - Building Image Repo on Objects.