You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Basic configurations
Hosting a static website
Copy page
Download PDF
Hosting a static website
You can use TOS to host a static website. First, store all contents of the website in a TOS bucket. Next, configure rules to host the website so that it can be accessed via the bucket's domain name. This topic explains how to configure these rules.​
Background information​
A static website consists of only static content, such as the homepage, images, and scripts. When configuring static website rules, you must specify the homepage. You can also choose to specify a default 404 page. If you do so, it will be returned when a 404 error occurs.​
Prerequisites​
  • You have uploaded the website content to the bucket and set the object or bucket permissions to "public read". See the following documentation for instructions:​
Notes​
  • Each bucket can only contain one static website hosting rule.​
  • A hosting rule will not take effect until you associate a custom domain with the bucket. For instructions, see Setting up a custom domain.​
  • Starting from October 18, 2022, for security and compliance reasons, if you use the bucket's default domain to access web page files with the MIME type text/html and extensions including .htm, .html, .jsp, .plg, .htx, and .stm, the response header will automatically include Content-Disposition:attachment. This means that, when you access web page files via a browser, the website will not preview the content directly. Instead, the content will be downloaded locally.​
tip​
If you wish to preview web pages directly, associate a custom domain with the bucket. When you access web page files using the associated custom domain, the web page content will be previewed directly. For instructions, see Setting up a custom domain.​
Configuration examples​
The static website feature in TOS includes built-in support for subdirectory homepages. This means that when you access a URL ending with a forward slash (/) under the root domain, the default homepage of the corresponding directory is returned.​
For example, if you have associated the custom domain www.test.com with a bucket, uploaded the homepage file index.html and the default 404 error file error.html to the bucket, and also uploaded the homepage file index.html to the subdirectory /subdir, the access rules are as follows:​
​
Access URL​
Result​
http://www.test.com/​
Returns http://www.test.com/index.html​
http://www.test.com/subdir/​
Returns http://www.test.com/subdir/index.html.​
http://www.test.com/test.jpg​
Retrieves test.jpg.​
http://www.test.com/object​
If object does not exist in the bucket, returns http://www.test.com/error.html.​
​
Steps​
  1. Log in to the TOS console.​
  1. In the left navigation pane, click Buckets. In the Buckets list, click the bucket you want to manage.​
  1. In the left navigation pane, select Basic configurations > Static website.​
  1. On the Static website page, click Set default page rule.​
  1. In the box that appears, set the following parameters and click Create.​
  • ​
    Parameter​
    Description​
    Default homepage​
    The default homepage returned when you access the static website. It only supports the .html format. Example:​
    ​
    <html>​
    <head>​
    <title>Home Page</title>​
    <meta charset="utf-8">​
    </head>​
    <body>​
    <h1>Welcome to TOS</h1>​
    <p>Welcome to TOS</p>​
    </body>​
    </html>​
    ​
    Default 404 page​
    (Optional) The page returned when a 404 error occurs. Example:​
    ​
    <html>​
    <head>​
    <title>Welcome to TOS</title>​
    <meta charset="utf-8">​
    </head>​
    <body>​
    <h1>Access denied</h1>​
    <p>This is error 404 page.</p>​
    </body>​
    </html>​
    ​
    ​
​
​
Last updated: 2026.07.01 14:48:56