Sites
A site is a static website stored on IOTA Storage, indexed by an object in your IOTA wallet and reachable through a subdomain or an IOTA Names name.
- Files. Each file of the site is a patch of a quilt: a blob owned by you and paid in IOTA, like any other.
- Index. A
Siteobject in your wallet (packagesites) has oneResourceper path, with the file's HTTP headers, the blob ID of its quilt, the patch (x-quilt-patch-internal-idheader) and its SHA-256. - Configuration. An optional
ws-resources.jsonfile in the site folder sets headers, routes, redirects, the site name and its metadata.
You publish and manage sites with the app or with the reference CLI. This section is the reference: how a site is served, its configuration file, how updates work, IOTA Names and the command line. The step-by-step guides are in the tutorials.
How a site is served
The portal serves every Site of the sites package at two kinds of address:
| Address | Example |
|---|---|
https://<site ID in base36>.iotastorage.com/<path> | The Site ID 0x… written in base36. |
https://<name>.iotastorage.com/<path> | https://blog.alice.iotastorage.com/ serves the site that the IOTA Names name blog.alice.iota points to. See IOTA Names. |
A portal can also show the sites of its users only at the address of their name: then the base36
address of one gives 404 (iotastorage.com shows both today).
The base36 form is the 32 bytes of the object ID written in base 36 (each leading zero byte is a
0). The app shows the URL of each site, and the CLI converts in both directions with
node site.mjs convert.
Review
On iotastorage.com, the portal shows a site only once its operator has reviewed it. What a site may not show (sexual, political, religious, violent or hateful content, impersonation, and more) is in the terms of use.
- A new site, and each change to one, is shown once it has been reviewed. Until then, the portal
answers
503with a Pending review page for each file or redirect that has not been reviewed; what was reviewed before is still served. - The review approves what it saw. It approves each file with its path, its content (its SHA-256) and its headers, and each redirect with its location and status. Changing the content or the headers of a file needs another review; uploading the same file again in another quilt does not.
- A rejected site gets
451(This content is not available). It stays in your wallet and on the network. - A site loads only its own files. So that what is shown is what was reviewed, the portal adds a
content-security-policythat lets a page load only files of its own site (anddata:andblob:URLs) and send forms only to it: fonts, scripts, styles or images from other sites do not load. Links to other sites work as always.
The app says so when you publish. The review runs on the operator's machines, without sending anything of the site to anyone. How long it takes is not guaranteed.
How the portal resolves a path
For each request, the portal reads the Site and the resource of the path from IOTA (it keeps what
it reads for 5 seconds, so an update of a site takes up to that long to show), and then tries, in
this order:
- The resource of the path.
/is/index.html, and a trailing slash is removed. <path>/index.html, if the path has no extension. So/docs/and/docsserve/docs/index.html.- A redirect of the site that matches the path: answers with its status (301, 302, 303, 307 or
308) and a
Locationheader. - A route of the site that matches the path: serves the resource it points to.
- The site's
/404.html, with status 404. - Otherwise, the portal's own "Page not found" page, with status 404.
The bytes come from the aggregator: the patch of the quilt, by its quilt patch ID. Before serving
them, the portal checks that their SHA-256 is the one the Site declares on IOTA.
Responses
A served resource carries the headers stored in its Resource (headers that are not valid in HTTP,
and those that the portal does not send, are left out; see
ws-resources.json), plus:
x-resource-iota-object-idandx-resource-iota-object-version: the dynamic field that holds the resource;x-iota-site: the ID of theSite;x-content-type-options: nosniff: the browser takes each file for thecontent-typethe site declares and does not guess another one;etag(with status 200): the SHA-256 of the file, in quotes, assha256sumprints it. WithIf-None-Matchand thatetag, the answer is304without the body. The portal checks the file first as for a200, so a file that expired gets its 404, not a 304;cache-control: no-cache, if the site sets neithercache-controlnorexpiresfor the file: a path can change with each update of the site, so the browser asks every time, and gets a304if nothing changed. For files that never change (names with a hash), set a longer one inws-resources.json;content-security-policy, the one of the review, after the site's own if it sets one (the browser applies both).
The portal does not serve service workers of the sites: a request for one (with the
Service-Worker: script header) gets 403. Installed in a visitor's browser, a service worker would
go on serving its copies of a site after the site changed or was blocked.
The portal only answers GET and HEAD. Errors:
| Status | When |
|---|---|
| 400 | The address or the path is not valid. |
| 404 | No site at that address; the name does not exist, expired, does not point to a site or is reserved; the page does not exist; or the data of the file is no longer available (it expired). |
| 403 | The script of a service worker: the portal does not serve them. |
| 405 | A method other than GET or HEAD. |
| 414 | The path is longer than 2048 characters. |
| 422 | The bytes do not have the SHA-256 that the site declares on IOTA, or the resource declares a quilt patch that is not valid. |
| 429 | Too many requests from the same IP; each MiB sent counts as one more request. Try again in a few seconds. |
| 451 | The operator of the portal has blocked the site, its name or the file: after a notice or an order about it, or because it breaks the terms of use. |
| 502 | A file of the site is larger than 32 MiB: the portal does not serve it. Store it as a blob and link to it from the site. |
| 503 | Pending review: the site, the file or the redirect has not been reviewed yet. Under maintenance: the sites of the users are paused for a while. Or the IOTA node or the aggregator did not respond, or the portal is making too many queries to IOTA at once. Try again later. |
| 508 | A redirect of the site points to the same path. |
Status of the portal
GET /_portal/status, on the host of the app (https://app.iotastorage.com/_portal/status), says
how the portal is serving the sites of its users; the app reads it when it loads, to show its
notices. It is specific to IOTA Storage:
{
"sitesPaused": false,
"sitesReview": true,
"sitesByName": false,
"filesPaused": false,
"appPaused": false,
"blocklist": { "sha256": "…", "bot": { "sha256": null, "sites": 0, "blobs": 0, "paused": [] }, "failed": false, "blobs": 0, "deletions": 0, "sites": 0, "names": 0, "sitesPaused": false, "sitesReview": 12, "sitesByName": false, "filesPaused": false, "appPaused": false }
}
| Field | Meaning |
|---|---|
sitesPaused | The sites of the users are not shown, for maintenance, and the app does not publish them. |
sitesReview | Sites are shown only once they have been reviewed. |
sitesByName | The sites of the users are served only at the address of their IOTA Names name, not at the one of their ID. |
filesPaused | The files are paused, for maintenance: the app does not store them, and the aggregator does not serve them to the public. |
appPaused | The portal serves a maintenance page instead of the app. |
blocklist | With what list of its operator the portal serves, as in the network status of the aggregator. null without a list. |
Quilts and costs
- The files to upload are grouped in quilts, from smallest to largest. With 100 shards a quilt holds up to 66 files. Since this network has few columns per quilt, a quilt larger than 1 MiB that would be more than 4 times the size of its files is split in two.
- The portal serves files of up to 32 MiB each: a larger one gives
502. Store it as a blob and link to it from the site. - Each resource is a dynamic field of the
Sitewith its storage deposit: about 0.005 IOTA per file, almost all of it deposit, which comes back to you when you destroy the site. - On testnet, the example site of the project (6 files) costs about 0.035 IOTA to publish, almost all of it deposit, plus a few thousand nanos of storage.
Expiration
A site is available as long as the blobs of its files are. Each purchase covers at most 53 epochs (53 days on testnet). Renew the site before it expires: see Update, renew and destroy. When a file has expired, the portal answers 404 with a page that says the content is no longer available.