Okay, this is the last article. In fact, from the organization of the original official document, this section is 3.3 -- after the iner, before the object, for the consistency of the overall idea of the API, I made the final part. This chapter is an interesting one in my opinion. You can directly configure swift as a static site as a data download site, which directly solves the problem of static site data backup.
So, let's continue happily = d
3.3. create static website)
You can use the swift account to create a static site on the Internet. This mode is usually used for anonymous requests. If you want to use authentication requests in this mode, you must setX-web-ModeSetTrue. FilterStaticwebIt should also be added to the configuration file/Etc/SWIFT/proxy-server.conf.In the pipeline after the middleware is authenticated.StaticwebThe middleware configuration must be added to pipeline, for example:
[Default]... [pipeline: Main] Pipeline = Healthcheck cache tempauth Staticweb Proxy- Server...[Filter: staticweb]Use =Egg: swift # staticweb # seconds to cache container x -Container-meta-web -* Header values. # cache_timeout = 300 # You can override the default log Routing For This filter here: # Set log_name = Staticweb # Set log_facility = Log_local0 # Set log_level = Info # Set access_log_name = Staticweb # Set access_log_facility =Log_local0 # Set access_log_level = Info # Set log_headers = False
Your public-readable container should containX-container-meta-web-IndexAndX-container-meta-web-ErrorThese two headers (X-container-meta-web-ErrorThis header will be discussed in "setting error pages for static sites" later ).
X-container-meta-web-IndexUsed to specify the website page (page, index.html file ). When a user enters your website for the first time, if he does not specify a special indexfile, your website will automatically display index.html to him. If you create a subdirectory for your site by creating a pseudo directory, the default access page name for each subdirectory will beX-container-meta-web-IndexThe specified page. If your pseudo directory does not contain the sameX-container-meta-web-IndexIf the specified index file has the same page name, a 404 error will be returned when you access this subdirectory.
You can also select to display the file list in the subdirectory instead of a webpage. To display the file list in a subdirectory, you only needX-container-meta-web-listpartsSetTrue. You can setX-container-meta-web-listings-CSSExample file format (such as lists.css ).
3.3.1. Static web middleware via SWIFT)
Example 3.38. Set container to public-readable
Set container to public readable. Once the container is set to public-readable, you can directly access the objects in the container, but you need to set the main URL of the site (that is, the URL of the container) and its subdirectories SET index file.
Swift post-R'. R :*'Container
Example 3.39. Set the index file of the site
Set the index file of the site. In this example, index.html is the default access page of the site.
Swift post-m'Web-index: index.html'Container
Example 3.40. enable file list
Enable file list. If you have not set the index file, you need to display the list of objects in the iner. The style setting command is in the next example.
Swift post-m'Web-Listings: True'Container
Example 3.41: Set the CSS style for the file list
Set a style for the file list.
Swift post-m'Web-listings-CSS: listings.css'Container
3.3.2. Set error pages for static websites)
You may need to set custom error pages for your site. Currently, only 401 (unauthorized) and 404 (not found) errors are supported. To implement custom error pages, you need to set the metadata HeaderX-container-meta-web-Error.
The true error page is based onStatus CodeAndX-container-meta-web-error name. For exampleX-container-meta-web-ErrorSetError.htmlWhen error 401 is displayed401error.htmlPage. Similarly, when Error 404 is displayed404error.htmlPage. Set as containerX-container-meta-web-ErrorYou can create error pages for these two types of errors, or do not create them to access public error pages.
You only need to set the whole site onceX-container-meta-web-ErrorYou can.
Example 3.42: Set an error page for a static website
Swift post-m'Web-error: error.html'Container
Any 2XX response indicates that the execution is successful.
Now, the official API of openstack object storage is translated! Don't ask me about Chapter 1st and Chapter 4th. I won't be able to turn it over! Chapter 2 mainly describes how to use curl to interact with SWIFT. It is relatively straightforward and doesn't have much to understand. Just look at it yourself. Don't be lazy. = P