Simple Hosting of Static Web Content on Oracle Cloud OCI

Published by Max Jahn on

What you should know: I am currently working for Oracle as Principal Cloud Architect, but any posts on this blog reflect my own views and opinions only.

Sometimes you just want to get a simple, static website up and running without much hassle. Be it the microsite to tell about your latest achievements or some error page explaining why your whole production site went down.

So it’s about firing up your favourite editor, write some html and upload it to a web host. If you do not have any web host running for this purpose, but have access to your Oracle Cloud account, then i will show you a really simple solution for this.

Object Storage to the Rescue

The easiest way to serve static content is probably not setting up your own nginx vm and put everything on it. Instead you can use a public object storage bucket. For example with the following command you will get a proper bucket.

oci os bucket create \
--public-access-type ObjectReadWithoutList \
--name site \
--compartment-id ocid1.compartment.oc1..aa

Once you got your bucket, you can start copying your content to the cloud. One drawback of using object storage is that it does not support any hierarchical structure, so everything will be lying in one big directory without any subdirectories. This might be ok on the server side, but really is some pain for the local development environment when trying to find your file to edit in that big pile of code. Luckily you can use a slash (“/”) in object storage object names, so “img/badger.jpg” is a perfectly valid name. The only thing to do is to rename your files accordingly after upload.

Say Hi to Staci

For this purpose i create a small tool called staci – the OCI static content importer. This tool will copy your local directory – including subdirectories – to your object storage bucket and rename the files.

Before running the tool, you need to have your OCI CLI set up. Staci will use the default profile defined in your config for connecting to OCI.

Then go to the directory containing a directory with your static web content and the staci binary. Then run staci with the arguments -source (directory) and -target (bucket name).

./staci -source site_content -target site

You will then be able to reach your content using your bucket URL, e.g. A drawback of not using a web server is that you do not have something like a default document, so you will not be able to go to“ to see the content.

HTTP Redirects for more friendly URLs

But as you probably do not want to hand out an URL like that anyway, i don’t see this a real issue. Because you probably will want to set up a simple http redirect from some of your domains to the start page of your static webpage. For example this is how it looks like at

If you moved your Domain to OCI, you of course will then use the built-in http redirect functionality available there.

So now you have your simple and cheap web hosting on OCI. And looking a bit forward, you can use Oracle Functions if you need some more functionality for that site.