Using CloudFiles To Host Static Websites.

Using CloudFiles To Host Static Websites

Cloud Files has the ability to host static websites such as .html files.
To do so you need to have a container that has cdn enabled.
For each container or pseudo directory you will need a main page such as index.html set with the header:
 X-Container-Meta-Web-Index.
For each object (file) you wish to be webpage you need to set the header to:  X-Container-Meta-Web-Index. If you do not have this header set for your prime page in each container or subfolder container you are going to host static content in, you will get a nasty little 404 error.

How do I pull of this epic awesomeness off? 

Here is the official Rackspace article to do this.

  1. Upload your content through: Control Panel CloudFiles gui tool, Cyberduck, or API .
  2.   Post the content with the header X-Container-Meta-Web-Index.
  3. CDN-enable your container.
  4. Go to your domain host and set up a CNAME to your CDN URL.

 

Example: Set up Static Web

  curl -X POST - -H "X-Container-Meta-Web-Index: index.html" -H "X-Auth-Token: 19264db3-c845-40ea-86ed-8a33d89bfe00" "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_a55df/MyLibrary/        

Once your container is configured for Static Web and your domain host has your CNAME recorded, you will get the following results.

Example: Container Setup for Static Web Site

  container/index.html
  container/page2.html
  container/subdir/index.html
  container/subdir/pageX.html

In the results below, the user’s CNAME is myhost, and the X-Container-Meta-Web-Index is set to index.html. The results on the right of the example are the pages that display in the Web browser.

Example: Static Web Site Enabled Container Results

  http://myhost                     Displays container/index.html
  http://myhost/page2.html          Displays container/page2.html
  http://myhost/subdir              Displays container/subdir/index.html
  http://myhost/subdir/             Displays container/subdir/index.html
  http://myhost/subdir/pageX.html   Displays container/subdir/pageX.html

Endnotes:

  1. Cloud Files: http://www.rackspace.com/cloud/cloud_hosting_products/files/
  2. the pseudo directory section of this guide: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Pseudo-Hierarchical_Folders_Directories-d1e1580.html
  3. Reduced the cost of Cloud Files by 33 percent: http://www.rackspace.com/blog/cloud-files-updates/

jim has written 83 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>