Skip to content

Bucket Website Support

jeniawhite edited this page Jun 1, 2020 · 14 revisions

You can use NooBaa Website Bucket to host static websites or static assets of your web application. A static website serves the website content over http/s and allows anonymous read access.

To host a static website on NooBaa, you configure a bucket for website hosting and then upload your website content to the bucket. When you configure a bucket as a static website, you must enable website hosting, set permissions, and create and add an index document and optional custom error document.

Configuring the bucket

For website buckets the "Bucket Policy" configuration should be set to allow anonymous GET requests.

Use aws-cli to set the bucket policy:

aws s3api gut-bucket-policy --bucket first.bucket 
aws s3api put-bucket-policy --bucket first.bucket --policy '{
     "Version": "2012-10-17",
     "Statement": [{
         "Sid": "PublicReadForGetBucketObjects",
         "Effect": "Allow",
         "Principal": "*",
         "Action": ["s3:GetObject"],
         "Resource": ["arn:aws:s3:::first.bucket/*"]
     }]
}'

Then the bucket website configuration should be set:

aws s3api put-bucket-website --bucket first.bucket --website-configuration '{
    "ErrorDocument": { "Key": "string" },
    "IndexDocument": { "Suffix": "string" },
    "RedirectAllRequestsTo": {
        "HostName": "string",
        "Protocol": "http" | "https"
    },
    "RoutingRules": [{
            "Condition": {
                "HttpErrorCodeReturnedEquals": "string",
                "KeyPrefixEquals": "string"
            },
            "Redirect": {
                "HostName": "string",
                "HttpRedirectCode": "string",
                "Protocol": "http" | "https",
                "ReplaceKeyPrefixWith": "string",
                "ReplaceKeyWith": "string"
            }
        }
        ...
    ]
}'

Website endpoints

(See https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html)

TODO: Document which endpoints can be used to access the website:

  • How to discover the endpoint addresses
  • How to use with OBC?
  • How to use without OBC?
  • Mention if we can use both http and https
  • Can we set custom bucket domain?

S3 Bucket Website Operations

  • Delete Bucket Website - Fully supported
  • Get Bucket Website - Fully supported
  • Put Bucket Policy - Fully supported except:
    • Routing Rules - not implemented
    • Custom error document - Supported?
Clone this wiki locally