Support: 1-800-961-4454
Sales Chat
1-800-961-2888

Rackspace Cloud Files: How To Create A Static Website

8

We frequently update our products, and Cloud Files is no exception. In this series of technical posts, we’ll dig into how developers using the Cloud Files API can leverage new capabilities in Rackspace Cloud Files.

You can now use your Cloud Files account to create a static website. First, you must CDN-enable a storage container. Any HTML or static web pages in the container will become available through a static website once you set the X-Container-Meta-Web-Index header to index.html or other index page of your choice. You may also create subdirectories in your website by creating pseudo-directories, as outlined in the pseudo directory section of this guide. Each pseudo-directory becomes a subdirectory in the website.

The page you set for X-Container-Meta-Web-Index becomes the index page for every subdirectory in your website; each pseudo-directory should contain a file with that name. So, if you set X-Container-Meta-Web-Index to index.html, you should have an index.html page in each pseudo-directory. If you do not have the named index page, visits to myhost/subdir/ will return a 404 error.

How To Set up a Static Website

  1. Upload your pages to a container.
  2. POST the X-Container-Meta-Web-Index on the storage container to set the index or other primary page of your website. You must write your storage URL and the container name to properly point to the container (<storage URL><container name>)
  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

This is just one of many new features in Rackspace Cloud Files that developers can take advantage of. Cloud Files customers are urged to try out this new feature in their next API project or add it to a current application. If you’re not yet using Cloud Files, sign up for an account and check it out. And now, using Cloud Files is more affordable since we reduced the cost of Cloud Files by 33 percent.

About the Author

This is a post written and contributed by Jerry Schwartz.

Jerry is a Senior Product Marketing Manager focusing on our cloud storage and managed storage portfolios. He joined Rackspace in 2007 and was the Product Manager for our Microsoft applications including SharePoint, Exchange, SQL and the Windows Server operating system. He has worked in the Rackspace Cloud since 2010 shaping many of Rackspace’s cloud offerings including Cloud Files, Cloud Block Storage, Cloud Backup, and Cloud Servers.

Jerry is a loyal Texas Longhorns fan and received his MBA from the University of Texas at Austin. Outside of Rackspace, you will likely find him on a jet ski at one of the lakes around San Antonio.


More
8 Comments

This is a welcome development. This time last year I had a requirement for this and I postulated with Rackspace support that there wasn’t really anything to stop me hosting a static site in a Cloud Files container using a CNAME but just that ominously it wasn’t “supported”.

The only downside is the sheer lack of truly static sites these days! But with some smart engineering/architecture it could prove very useful in a small number of cases. Thanks for adding the feature!

avatar Simon on June 26, 2012 | Reply

Here is also an example which shows how to do that using Apache Libcloud – http://libcloud.apache.org/docs/storage-examples.html#publishing-a-static-website-using-cloudfiles-driver

avatar Tomaz Muraus [Racker] on June 26, 2012 | Reply

nice feature, welcome one, but too late. would be great to have a UI to configure thru our a/c.

@Tomaz Muraus – Tx for the link on Libcloud, looks like a really nice API to use.

avatar jinishans on July 10, 2012

Sharing a file from one person to another is file sharing.

avatar file sharing on November 28, 2012 | Reply

file hosting and web hosting is same . to host a site we require domain name.

avatar what is filehosting on November 28, 2012 | Reply

Can you please show how to do this using a CloudFiles in another location such as the new Sydney DC?

avatar Dan on August 2, 2013 | Reply

Hi Dan,

One of our Cloud Files Developers wrote a great blog on serving static websites from Cloud Files using cURL. Check it out here: http://blog.scottic.us/static-site-with-cloudfiles-staticweb.html

As noted in the blog: if you want to use another region, you need to grab the cloudFiles:publicURL from the region you want. The endpoints are all listed in the Auth 2.0 return data, but really you just need to substitute ord1 or syd2 for dfw1 in your endpoint.

avatar Jerry Schwartz [Racker] on August 7, 2013

Hi Jerry, I want to thank you for your great work. You have given excellent information and I would like to share it with my friends…Thanks for it.

avatar cheap vps hosting on August 16, 2013 | Reply

Leave a New Comment

(Required)


Racker Powered
©2014 Rackspace, US Inc.