Skip to content

How to create a static website

Estimated time to read: 2 minutes

In this tutorial you will learn how to create a static website using Swift on Fuga Cloud. Static websites are more secure, the website loads faster and are highly scalable.

Prerequisites

For this tutorial you need the following:

  • Active Fuga Cloud account.

Step 1 - Create Team credentials.

  1. Login to your Fuga Cloud account and go to Access > Credentials. Select on the op of the screen Team credentials. Create a new Team credential by clicking on the orange Team credentials + button.
  2. A window will appear with the credentials Username and Password, securely store the password in your password manager click on ‘Ok’.
  3. After creating the new Team credentials, click on ‘OpenRC’ and download the file on your device.

Step 2 - Create Object Store

Open your CLI client and follow the instructions below:

  1. Source the OpenRC file:
    source openrc.sh
    
  2. When prompted, enter your previous saved password:
    Enter password for TEAM Credential with ID <PROJECT_ID>
    
  3. Instal the swift client on your machine.
    sudo apt install python3-swiftclient 
    
  4. Create a container with public read access rights:
    swift post -r '.r:*' <CONTAINER_NAME>
    
  5. Upload your html file:
    swift upload <CONTAINER_NAME> index.html
    
  6. Set an index file directive:
    swift post -m 'web-index:index.html' <CONTAINER_NAME>
    
  7. Turn on listing and set public read access rights:
    swift post -r '.r:*,.rlistings' <CONTAINER_NAME>
    swift post -m 'web-listings: true' <CONTAINER_NAME>
    
  8. Upload your html error file
    swift upload <CONTAINER_NAME> <HTML_ERROR_FILE>
    
  9. Set an error file:
    swift post -m 'web-error:error.html' <CONTAINER_NAME>
    

Step 3 - Connect to the website

Go to the Fuga dashboard and go to Storage > Object store. Find your container and click on the three dots "...", and click on 'View Details'. You will get the information of your Container. Copy the Swift URL and past it in your browser to connect with your Static website.

Below you can see an example of an URL:

https://core.fuga.cloud:8080/swift/v1/<PROJECT_ID>/<CONTAINER_NAME>/index.html

An alternative address is also available with the following URL syntax:

http://<CONTAINER_NAME>.<PROJECT_ID>.s3-website.core.fuga.cloud/

Conclusion

In this tutorial you have learned how to set up your team credentials, upload your index.html file and set up a static website in Fuga Cloud.