Host a website for free on Amazon S3 with SSL

0

  1. Create a bucket called www.example.com. It's not necessary but I also recommend turning on versioning so it's possible to rollback changes
  2. Properties > Static website hosting > Turn on
  3. Permissions > Block Public Access
    • uncheck "Block All public access"
    • check "Block public access to buckets and objects granted through new access control lists (ACLs)"
    • check "Block public access to buckets and objects granted through any access control lists (ACLs)"
  4. Permissions > Bucket Policy

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "PublicReadForGetBucketObjects",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::www.example.com/*"
            }
        ]
    }
    
  5. On your domain host: Subdomain forward example.com → http://www.example.com, Permanent redirect (301), Forward path, Enable SSL

  6. Go to https://console.aws.amazon.com/acm/home > create a certificate for example.com and www.example.com and validate

  7. Go to https://console.aws.amazon.com/cloudfront/home > Create distribution

    • Origin Domain Name: www.example.com.s3-website-us-east-1.amazonaws.com
    • Viewer Protocol Policy: Redirect HTTP to HTTPS
    • Compress Objects Automatically: yes
    • Alternate Domain Names (CNAMEs): example.com www.example.com (on separate lines)
    • Default Root Object: index.html
    • SSL Certificate > Custom SSL Certificate and select certificate from previous step
  8. www CNAME xxx.cloudfront.net.

  9. To update the cache after updating the website, go to CloudFront and create an invalidation with object paths /

  • 0 posts
  • 0 subtopics
  • 6 months ago by vince