Advanced Swift Features: Part 2


This is the second in a series of blog posts covering the advanced features of Swift. All features require the latest version of Swift from the OpenStack Grizzly release. These features also assume that you are already running a Swift storage cluster.

Swift Web Access

Normally, data stored in Swift is accessed via a separate tool such as the "swift" command-line tool. This isn't the most user-friendly way to interact with Swift, especially if you want to allow public access to data.

Swift has the ability to allow users to access stored data by HTTP '€” meaning, your web browser. Here's how to set it up:

Implementing Swift StaticWeb Support

On your Swift proxy server, you'll want to make a few changes to the /etc/swift/proxy-server.conf file.

In the [pipeline:main] section, add staticweb somewhere in the middle of the pipeline:

pipeline = healthcheck cache swift3 s3token authtoken keystone staticweb proxy-logging container_quotas account_quotas proxy-server

Next, add a filter section for staticweb at the bottom of the file:


Using the StaticWeb Feature

First, let's create a container where all of the public data will reside:

$ swift post public

Next, modify the ACL to allow everyone to be able to read the public container:

$ swift post -r '.r:*' public

If you'd like to utilize a standard "index.html" page, run the following command:

$ swift post -m 'web-index:index.html' public

Or if you'd like to support a standard directory listing of files:

$ swift post -m 'web-listings: true' public

With all of this in place, you can now start uploading data to the public container:

$ echo "Hello, World!" > hello.txt
$ swift upload public hello.txt

To access the data through your web browser, make note of your OpenStack project ID. For this example, I'll use 628df59f091142399e0689a2696f5baa. Point your browser to:

joe advanced swift part two

You should see a listing of all files uploaded to the public container. In this case, hello.txt. You can click on hello.txt to view it or directly access it by the URL:

Note: Instead of using the swift command-line tool to upload files, you can also use the Horizon Dashboard. Just make sure the container you are uploading to has the ACL, web-index, and web-listings configured as mentioned above '€” that part must be done with the swift tool.

See previous post '€” Advanced Swift Features: Part 1