You may want to host a static website on your Object Store space, because it's cheap and convenient .
There is lot of static website generators, like Hugo or Jekyll.
Warning: SSL certificate will not be valid for your domain / subdomain
Set public read acces to your container
First thing is to set the read ACLs on your container, to let public access to your files.
All files in your container will become public readable, so a good idea is to create a specific container for your website.
$ openstack container create website $ swift post -r '.r:*,.rlistings' website
Upload your website
$ swift upload website <files> $ swift upload website index.html
Define the reference web page (index file)
For this example first page is
swift post -m 'web-index:index.html' website
Now you should be able to see your website with default url: https://pub1-api.cloud.infomaniak.ch/object/v1/AUTH_d7a1d09c0323488aa00d9e163f3655bf/website/
Where AUTH_d7a1d09c0323488aa00d9e163f3655bf is refering to AUTH_
To enable directory listing, you won't need to setup the reference web page (index file) but you will need to modify your read ACL and to add this meta:
swift post -r '.r:*,.rlistings' website swift post -m 'web-listings: true' website
You can of course use index file and directory listing on a single container if you want.
You can customize the listing style sheet, with another meta parameter referencing your CSS file:
swift post -m 'web-listings-css:listings.css' website
And even allow custom error files:
swift post -m 'web-error:error.html' website
Then 401's should load 401error.html, 404's should load 404error.html, etc.
Last thing if you uploaded 0-byte objects (like directories):
swift post -m 'web-directory-type:text/directory' website
Now 0-byte objects with a content-type of text/directory will be treated as directories rather than objects.
Check your setup
You can verify ACLs and meta set on your container with command:
$ swift stat --lh website Account: AUTH_d7a1d09c0323488aa00d9e163f3655bf Container: website Objects: 1 Bytes: 116 Read ACL: .r:*,.rlistings Write ACL: Meta Web-Listings: true Meta Web-Index: index.html Meta Web-Listings-Label: /object
API url specific case
You can access your files through API url like https://s3.pub1.infomaniak.cloud/object/v1/AUTH_d7a1d09c0323488aa00d9e163f3655bf/website/, but by default it won't work, because Swift will look for /v1/AUTH_d7a1d09c0323488aa00d9e163f3655bf/website/index.html file and we have in our case /objects//v1/AUTH_d7a1d09c0323488aa00d9e163f3655bf/website/index.html path for our index file. We can add a specific meta to add this "/object/" path in url:
$ swift post -m 'web-listings-label:/object/' website
Access (urls) for your content
You can access your content through url https://s3.pub1.infomaniak.cloud/object/v1/AUTH_d7a1d09c0323488aa00d9e163f3655bf/website/, but this is not so fancy...
Swift supports some convinient shortcuts, with project id and container. You can then use:
- https://d7a1d09c0323488aa00d9e163f3655bf.s3.pub1.infomaniak.cloud/website/ (\<projectid>.s3.pub1.infomaniak.cloud/\<container>)
- or https://website.d7a1d09c0323488aa00d9e163f3655bf.s3.pub1.infomaniak.cloud/ (\<container>.\<projectid>.s3.pub1.infomaniak.cloud)
SSL certificate can be invalid for that urls.
Using your own domain
Swift supports also a middleware to redirect a domain or subdomain to your static website. To enable that, you will need to configure your DNS and add a CNAME record to your domain (/subdomain). Point your CNAME record to the Swift full url (\<container>.\<projectid>.s3.pub1.infomaniak.cloud) and Swift will do the match.
$ host test1.mydomain.net test1.mydomain.net is an alias for website.d7a1d09c0323488aa00d9e163f3655bf.s3.pub1.infomaniak.cloud.
$ curl -k https://test1.mydomain.net <html> ...