Skip to main content
Host a static website
Last update:

Host a static website

In the public container of the object storage, you can:

  • host a static website for quick file access and lower storage costs;
  • configure error page. If the user requests a non-existent object, the request will be processed according to the settings: another object will be returned or a redirect to an external URL will occur.

Host a static website

Static sites consist of a set of files (HTML, JS, graphics, fonts) that can be stored as objects in a container. The site will open at the container's public domain or user domain if it is added to the container.

There are two ways to host a website:

  • hosting — you specify the main page of the website, which is stored as an object in a public container;
  • web listing — instead of displaying the main page, you enable the return of the list of objects in the container and set your CSS styles.

Configure hosting

  1. In the container upload an object — an HTML file that will be the main page.
  2. In the control panel, go to the Object Storage section → Containers.
  3. Open the container page → Website tab.
  4. In the Website block, turn on the toggle switch.
  5. Open the Hosting tab.
  6. Enter path to object from the main page with the extension .html.
  7. Click Save.

Configure web listing

  1. If you want to store a CSS style file in a container, upload it.

  2. In the control panel go to the section Object StorageContainers.

  3. Open the container page → tab Website.

  4. In the Website block, turn on the toggle switch.depends on where the file is stored:

    • in the container, enter path to object with CSS styles;
    • on a third—party resource — enter the URL of the CSS styles file.
  5. Click Save.

Configure the error page

If users access a non-existent object, an error will occur, which can be handled in two ways:

Return an object from a container

  1. In the control panel, go to the Object Storage section → Containers.
  2. Open the container page → tab Website.
  3. In the block Error page Turn on the toggle switch.
  4. Optional: If you want the object to return with the 200 code, select it as the response code. By default, the response to the request will be with the code 400.
  5. In the Resource field, enter path to object with the error page with the extension `.html'.
  6. Click Save.

Perform request forwarding

  1. In the control panel, go to the Object Storage section → Containers.
  2. Open the container page → tab Website.
  3. In the block Error page Turn on the toggle switch.
  4. Select the response code 307.
  5. In the Resource field, enter a valid external URL to which redirection will be performed if the requested object is missing.
  6. Click Save.

Paths to objects

When hosting a static website or [configuring the error page] (#configure-error-page), you will need to enter the path to the object in the container — absolute or relative.

Absolute path

The absolute path always starts with the character / and is specified in the format /<prefix>/<object_name>, where:

  • <prefix> — prefix (path to the object) — if available;
  • <object_name> is the name of the object with the extension.

If an absolute path is specified, when requesting an object, the storage logic will always search for it relative to the root of the container — at the address <uuid>.selstorage.ru /<container_name>. If there is a prefix after the container name in the request, it will be ignored.

If you specify an incorrect path, the object will not be returned.

note

For example, if the full address of the object is <uuid>.selstorage.ru/container/prefix/file.html , you specified as the path /prefix/file.html and the request is executed at the address <uuid>.selstorage.ru/container/prefix /, the object will be returned.

Relative path

The relative path never starts with the / character and is specified in the format <prefix>/<object_name> or <object_name>, where:

  • <prefix>/ — optional: prefix (path to the object);
  • <object_name> is the name of the object with the extension.

If a relative path is specified, when requesting an object, the storage logic will search for it, taking into account the prefix specified in the request to the container.

note

For example, if the full address of the object is <uuid>.selstorage.ru/container/prefix/file.html , you specified as the path file.html and the request is executed at the address <uuid>.selstorage.ru/container/prefix /, the object will be returned.

note

For example, if the full address of the object is <uuid>.selstorage.ru/container/prefix/file.html , you specified as the path prefix/file.html and the request is executed at the address <uuid>.selstorage.ru/container/prefix /, the object will not be returned because the storage logic will search for the object at a non-existent address <uuid>.selstorage.ru/container/prefix/prefix/file.html .