Skip to main content

Static Website

You can host a static website using Arvancloud Object Storage. A static website, unlike dynamic websites that rely on server-side processing with ASP.NET and PHP scripts, consists of web pages with static content.

Setting up Static Website

To set up a static website, you must first enable this feature on the bucket and then upload the index and error files with public access.

To activate this feature, select the bucket you want and customize "Static Website" from the "Operations" menu.

On the new page, enable "Static Website Hosting" and specify the index or default file name and error file. Finally, click "Apply Changes" to save the settings.

If these two names are not defined, the system will automatically choose the names index.html and error.html for them.

It is always possible to change these names after saving and applying the changes at this stage.

Static Website Endpoint

When you configure your bucket for a static website, these settings will be available through an address called Endpoint. In fact, website endpoints are different from the endpoints you send Object Storage API requests.

Depending on your bucket region, the static website endpoint will look like this:

http://bucket-name.s3-website.region.arvanstorage.ir

You can also find this URL in the "Static Website" section of the bucket:

If you have configured the Index file in your bucket, by default, when you open the Endpoint address, the main page of the website will open with the contents of the Index file.

Configuring index.html

When you enable static website on your bucket, you need to configure an index file for it. The index file is a web page that Arvancloud sends to your static website users in response to requests. For example, if a request is sent to https://example.com, the website's Index page will be displayed.

To set up a static website, you need to upload an index.html file (or any other arbitrary name) to the bucket and enter its name in the settings. Doing this, you will see this page when you enter your static website address.

For example, you can save the following content in a file called index.html Save 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 a directory on your static website, you can use the "Create Folder" option. For example, if you create a folder called images and upload an index.html file (or any other desired name you entered in the settings) in it, you can view its contents by entering the following addresses:

https://bucket-name.s3-website.region.arvanstorage.ir/images/

https://bucket-name.s3-website.region.arvanstorage.ir/images

Configuring error.html

Arvancloud displays error.html file content (or whatever name you want) for 4xx errors.

For example, you can save the following content in a file called error.html, save 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 Object Permissions

After uploading your static website files, you need to enable the Public Access of these files so that users can see them.

Note that there is no need to set Public Access on the bucket.

Setting up Custom Domain

Instead of accessing a static website through the Arvancloud Endpoint, you can use your own domain that you have set up in Arvancloud CDN. You just need to activate this feature on the static website address of your bucket and choose the desired domain.

The guide to setting up a Custom Domain for Arvancloud buckets will help you.