Skip to main content

Host a static website

Last update:

Host a static website

In a public object store container, you can:

  • static website for quick access to files and reduced storage costs;
  • customize the error page. If the user requests a non-existent object, the request will be handled according to the settings: another object will be returned or a redirect to an external URL will take place.

Host a static Web site at

Static sites consist of a set of files (HTML, JS, graphics, fonts) that can be stored as objects in a container. The site will be opened at of the container's public domain or user domainif 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.

Set up hosting

  1. In the container load the object — HTML file, which will be the home page.
  2. В control panels go to Object StorageContainers.
  3. Open the container page → tab Web site.
  4. In the block Web site turn on the toggle switch.
  5. Open the tab Hosting.
  6. Enter object path with a home page extension .html.
  7. Click Save.

Customize web listing

  1. If you want to store the CSS styles file in a container, download it.

  2. В control panels go to Object StorageContainers.

  3. Open the container page → tab Web site.

  4. In the block Web site turn on the toggle switch. from where the file is stored:

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

Customize error page

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

Return object from container

  1. В control panels go to Object StorageContainers.
  2. Open the container page → tab Web site.
  3. In the block Error page turn on the toggle switch.
  4. Optional: If you want the object to return with code 200, select it as the response code. By default, the response to the request will be code 400.
  5. In the field Resource enter object path with an error page with the extension .html.
  6. Click Save.

Perform request forwarding

  1. В control panels go to Object StorageContainers.
  2. Open the container page → tab Web site.
  3. In the block Error page turn on the toggle switch.
  4. Select answer code 307.
  5. In the field Resource enter a valid external URL to which to redirect if the requested object does not exist.
  6. Click Save.

Pathways to facilities

At hosting a static website or error page customization you will need to enter the path to the object in the container — absolute or relative.

The Absolute Way

The absolute path always begins with a symbol / and is specified in the format /<prefix>/<object_name>, where:

  • <prefix> — prefix (path to the facility) — if available;
  • <object_name> — 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 the request has a prefix after the container name, it will be ignored.

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

note

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

Relative path

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

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

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

note

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

note

For example, if the full address of an object <uuid>.selstorage.ru/container/prefix/file.htmland the path you gave prefix/file.html and the request is executed at <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.