Host a static website
In a public object store container, you can:
- host a static Web site for quick access to files and reduced storage costs;
- customize 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 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 address of the container's public domain or user domain if added to the container.
There are two ways to host a website:
- hosting — you specify the home page of a website, which is stored as an object in a public container;
- web listing — Instead of displaying the main page, you include returning a list of objects in the container and set your CSS styles.
Set up hosting
- In the container, load an object — an HTML file, which will be the main page.
- In the Control Panel, on the top menu, click Products and select Object Storage.
- Go to the Containers section.
- Open the container page → Website tab.
- In the Website block, turn on the toggle switch.
- Open the Hosting tab.
- Enter the path to the homepage object with a
.html
extension. - Click Save.
Customize web listing
-
If you want to store the CSS styles file in a container, upload it.
-
In the Control Panel, on the top menu, click Products and select Object Storage.
-
Go to the Containers section.
-
Open the container page → Website tab.
-
In the Website block, turn on the toggle switch.
-
Open the Web Listing tab.
-
Enter the address of the CSS styles file. The format of the address depends on where the file is stored:
- in the container — enter the path to the object with CSS styles;
- on a third-party resource — enter the URL of the file with CSS styles.
-
Click Save.
Customize 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
- In the Control Panel, on the top menu, click Products and select Object Storage.
- Go to the Containers section.
- Open the container page → Website tab.
- In the Error Page block, 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 Resource field, enter the path to the object with the error page with the
.html
extension. - Click Save.
Perform request forwarding
- In the Control Panel, on the top menu, click Products and select Object Storage.
- Go to the Containers section.
- Open the container page → Website tab.
- In the Error Page block, turn on the toggle switch.
- Select answer code 307.
- In the Resource field, enter a valid external URL to which to redirect if the requested object does not exist.
- Click Save.
Paths to facilities
When hosting a static website or customizing an error page, you will need to enter the path to the object in the container — absolute or relative.
The Absolute Way
The absolute path always starts with a /
character and is specified in the format /<prefix>/<object_name>
, where:
<prefix>
— prefix (path to the object) — 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 container root — at <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 invalid path, the object will not be returned.
For example, if the full address of the object is<uuid>.selstorage.ru/container/prefix/file.html
, you specify /prefix/file.html
as the path, 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 the object is<uuid>.selstorage.ru/container/prefix/file.html
, you specify file.html
as the path, and the request is executed at <uuid>.selstorage.ru/container/prefix/
, the object will be returned.
For example, if the full address of the object is<uuid>.selstorage.ru/container/prefix/file.html
, you specify prefix/file.html
as the path, and the query is performed at <uuid>.selstorage.ru/container/prefix/
, the object will not be returned because the storage logic will search for the object at the non-existent address <uuid>.selstorage.ru/container/prefix/prefix/file.html
.