object-api/v1/section_object-api-create-website.xml
Diane Fleming ab048b233d Remove unneeded files and create master pom.xml file
Change-Id: I6970a2c5ce823936731ad33b83bd06df8bf0da3b
author: diane fleming
2014-05-14 12:52:27 -05:00

103 lines
5.7 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:id="static-website">
<title>Create static website</title>
<para>To discover whether your Object Storage system supports this
feature, see <xref linkend="discoverability"/>. Alternatively,
check with your service provider.</para>
<para>You can use your Object Storage account to create a static
website. This mode is normally only active for anonymous
requests, which provide no authentication token. To use it
with authenticated requests, set the header
<literal>X-Web-Mode</literal> to <literal>TRUE</literal>
on the request. To determine whether the static website
feature is enabled, contact your service provider.</para>
<para>For example:</para>
<programlisting language="ini"><xi:include href="samples/proxy-server-excerpt.conf" parse="text"/></programlisting>
<para>Your publicly readable containers are checked for two
headers, <literal>X-Container-Meta-Web-Index</literal> and
<literal>X-Container-Meta-Web-Error</literal>. (The latter
header is discussed below, under <link
linkend="Set_Error_Pages_for_Static_Website-dle4005">Set
error pages for static website</link>.) With
<literal>X-Container-Meta-Web-Index</literal>, you
determine the index file (or default page served, such as
<literal>index.html</literal>) displays your website. When
someone initially enters your site, they don't have to specify
the index file; index.html file displays automatically. If you
create sub-directories for your site by creating
pseudo-directories in your container, the index page displays
by default for each sub-directory. If your pseudo-directory
does not have a file with the same name as your index file,
visits to the sub-directory return a 404 error.</para>
<para>You also have the option of displaying a list of files in
your pseudo-directory instead of a web page. You do this by
setting the <literal>X-Container-Meta-Web-Listings</literal>
header to <literal>TRUE</literal>. You may add style to your
file listing by setting
<literal>X-Container-Meta-Web-Listings-CSS:</literal> to a
style sheet (for example,
<literal>lists.css</literal>).</para>
<section xml:id="Examples_for_static_web-dle4025">
<title>Static web middleware through swift</title>
<example>
<title>Make container publicly readable</title>
<para>Make the container publicly readable. Once the
container is publicly readable, you may access your
objects directly, but you must set the index file to
browse the main site URL and its
sub-directories.</para>
<screen><prompt>$</prompt> <userinput>swift post -r '.r:*' container</userinput></screen>
</example>
<example>
<title>Set site index file</title>
<para>Set the index file. In this case,
<literal>index.html</literal> is the default file
displayed when the site displays.</para>
<screen><prompt>$</prompt> <userinput>swift post -m 'web-index:index.html' container</userinput></screen>
</example>
<example>
<title>Enable file listing</title>
<para>Turn on file listing. If you do not set the index
file, list the objects in the container. Instructions
on styling the list with the CSS follow.</para>
<screen><prompt>$</prompt> <userinput>swift post -m 'web-listings: true' container</userinput></screen>
</example>
<example>
<title>Enable CSS for file listing</title>
<para>Style the file listing.</para>
<programlisting language="ini"><xi:include href="samples/file-listings-css-set-req.txt" parse="text"/></programlisting>
</example>
</section>
<section xml:id="Set_Error_Pages_for_Static_Website-dle4005">
<title>Set error pages for static website</title>
<para>You can create and set custom error pages for visitors
to your website; currently, only 401 (Unauthorized) and
404 (Not Found) errors are supported. To do this, set the
metadata header,
<literal>X-Container-Meta-Web-Error</literal>.</para>
<para>Error pages are served with the &lt;status&gt; code
pre-pended to the name of the error page you set. For
instance, if you set
<literal>X-Container-Meta-Web-Error</literal> to
<literal>error.html</literal>, 401 errors will display
the page <literal>401error.html</literal>. Similarly, 404
errors will display <literal>404error.html</literal>. You
must have both of these pages created in your container
when you set the
<literal>X-Container-Meta-Web-Error</literal>
metadata, or your site will display generic error
pages.</para>
<para>Set the <literal>X-Container-Meta-Web-Error</literal>
metadata once for your entire static website.</para>
<example>
<title>Set error pages for static website request</title>
<programlisting language="ini"><xi:include href="samples/error-page-set-req.txt" parse="text"/></programlisting>
</example>
<para>Any 2<varname>nn</varname> response indicates
success.</para>
</section>
</section>