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 get-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

Discover the endpoint addresses with the following options:

  • Run noobaa-operator status command which will output the S3 Addresses
  • View the NooBaa CR (kubectl get -o yaml noobaas noobaa -n namespace_name) and locate the serviceS3 field

These are the protocols for the endpoints:

  • HTTP (not implemented)
  • HTTPS (supported)

These are the types of endpoints:

bucket_name can be either OBC or non-OBC bucket

S3 Bucket Website Operations

  • Delete Bucket Website - Fully supported
  • Get Bucket Website - Fully supported
  • Put Bucket Website - Fully supported except:
    • Routing Rules - not implemented
Clone this wiki locally