Search code examples
amazon-s3dnsamazon-cloudfrontamazon-route53hsts

AWS static site endpoint not loading correctly


I followed quite a complicated AWS guide on setting a static hosting for my website, and it’s currently not loading, not sure why. What I have done:

  1. Created S3 bucket for the contents of the site estimate.dev
  2. Uploaded index.html to the root of the S3 bucket
  3. Unblocked all access to public in the "Prermissions -> Block Public Access" tab
  4. Added Bucket policy for public access:
    {
        "Version": "2012-10-17",
        "Id": "PolicyForPublicWebsiteContent",
        "Statement": [
            {
                "Sid": "PublicReadGetObject",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::estimate.dev/*"
            }
        ]
    }
  1. Added “Static website hosting” feature pointing to the domain estimate.dev and index file index.html
  2. Added Route 53 zone for estimate.dev with auto-generated SOA and NS records. Set TTL of 60 seconds for each. Imag
  3. Added A record pointing to my S3 bucket (selected in combobox) Image
  4. Changed nameservers in my registrar's control panel to point to AWS nameservers listed in SOA record Image
  5. A day passed

Now the troubleshooting part:

  1. On my PC estimate.dev resolves to AWS IP (it was resolving Registrar IP 2 days ago)
  2. These urls perfectly return the contents of my website (just one page, index.html): http://estimate.dev.s3-website-us-east-1.amazonaws.com/ https://s3.amazonaws.com/estimate.dev/index.html
  3. These urls [http://estimate.dev] & [https://estimate.dev] return ERR_CONNECTION_TIMED_OUT in Chrome after loading for some time

I tried to delete A record and add a CNAME but it does not allow me to select my S3 bucket there. So I reverted back to A record.

What do I miss here?


Solution

  • Everything is correct except S3 website endpoint (not the REST API) doesn't support HTTPS and many modern browsers tries for https because of HSTS policy and you'll see connection timeout.

    To make it work on HTTPS, you can use CloudFront and set up using below link:

    https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/