Static Website
With the static website feature of Arvancloud Object Storage, you can use this product to host a static website. A static website, unlike dynamic websites that rely on server-side processing and ASP.NET and PHP scripts, consists of web pages with static content.
Enabling a Static Website
To set up a static website, you first need to enable this feature on the bucket and then put the index and error files in it with public access.
To enable this feature, select the bucket you want and edit the static website feature in the Actions section.
On the new page, enable Static Website and specify the names of the index (default) file and the error file. Finally, click Apply Changes to save the settings.
If these two names aren't defined, the system automatically chooses index.html and error.html for them.
You can always change these names after saving and applying the changes in this step.
Static Website Endpoint Address
When you configure your bucket for a static website, these settings are available through Object Storage's static website address. In fact, website endpoints differ from the endpoints you send API requests to.
Depending on your bucket's region, the static website endpoint is:
http://bucket-name.s3-website.region.arvanstorage.ir
You can also see this URL in the bucket's Static Website section.
If you've configured the index file in your bucket, by default, when you open the endpoint address, the website's home page opens with the content of the index file.
Configuring the index.html File
When you enable a static website on your bucket, you need to configure an index file for it. The index file is a web page that Arvancloud sends in response to requests to your static website's address. For example, if a request is sent to https://example.com, this website's index page, also called the default page, is shown.
To set up a static website in Object Storage, you also need to upload an index.html file (or any other name you like) to the bucket and enter its name in the settings. This way, you'll see this page when you go to your static website's address.
For example, you can save the following content in a file named index.html and upload it to your bucket:
<!DOCTYPE html>
<html>
<head>
<title>My Static Website</title>
</head>
<body>
<h1>Welcome to My Static Website</h1>
<p>This is a sample index.html file for a static website.</p>
</body>
</html>
If you need to define directories on your static website, you can use Create Folder. For example, if you create a folder named images and upload an index.html file (or any other name you entered in the settings) to it, you can see its content at the following addresses:
https://bucket-name.s3-website.region.arvanstorage.ir/images/
https://bucket-name.s3-website.region.arvanstorage.ir/images
Configuring the error.html File
For 4xx errors, Arvancloud Object Storage shows the content of the error.html file (or any other name you set).
For example, you can save the following content in a file named error.html and upload it to your bucket:
<!DOCTYPE html>
<html>
<head>
<title>Error</title>
</head>
<body>
<h1>Oops! An error occurred.</h1>
<p>We're sorry, but something went wrong.</p>
<p>Please try again later.</p>
</body>
</html>
Setting File Access
After enabling the static website and uploading its files, you need to enable public read on these files so users can see them.
Note that there's no need to set public access on the bucket.
Setting a Custom Domain
Instead of accessing the static website through the Arvancloud Object Storage endpoint, you can use your own domain that you've set up in the Arvancloud CDN. To do this, simply enable this feature on your bucket's static website address and specify the domain you want.
The guide to setting a custom domain for Arvancloud Object Storage buckets helps you with this.