Host a static website
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
- In the container load the object — HTML file, which will be the home page.
- В control panels go to Object Storage → Containers.
- Open the container page → tab Web site.
- In the block Web site turn on the toggle switch.
- Open the tab Hosting.
- Enter object path with a home page extension
.html
. - Click Save.
Customize web listing
-
If you want to store the CSS styles file in a container, download it.
-
В control panels go to Object Storage → Containers.
-
Open the container page → tab Web site.
-
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.
-
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
- В control panels go to Object Storage → Containers.
- Open the container page → tab Web site.
- In the block Error page turn on the toggle switch.
- 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.
- In the field Resource enter object path with an error page with the extension
.html
. - Click Save.
Perform request forwarding
- В control panels go to Object Storage → Containers.
- Open the container page → tab Web site.
- In the block Error page turn on the toggle switch.
- Select answer code 307.
- In the field Resource enter a valid external URL to which to redirect if the requested object does not exist.
- 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.
For example, if the full address of an object <uuid>.selstorage.ru/container/prefix/file.html
and 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.
For example, if the full address of an object <uuid>.selstorage.ru/container/prefix/file.html
and the path you gave file.html
and the request is executed at <uuid>.selstorage.ru/container/prefix/
the object will be returned.
For example, if the full address of an object <uuid>.selstorage.ru/container/prefix/file.html
and 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
.