Hosting a static (https) web site on S3 using a custom domain name

In this blog, I will describe how I created a static web page for my example.vdzon.com static website.

Step 1: Create a certificate for https:

  • Set region to ‘US East (Virginia)’ (all certificates must be created in this region)
    In aws console: open the AWS Certificate Manager and choose ‘Provision Certificates’
  • Choose ‘request a public certificate’ and use ‘example.vdzon.com’ for the domain name
    • domain names: example.vdzon.com
    • klik next
    • choose a validation method: choose DNS validation
    • klik ‘review’
    • klik ‘confirm and request’
    • In the next page, you can see a pending state for each domain name. By opening the entry, you can see which DNS entry must be created to finish the validation process. These entries must be created by yourself on your DNS service provider.
      eg:
      name: _8a9653a2eca10348223a72e1047419b1.example.vdzon.com
      type: CNAME
      value: _c334fdd641ea0a5bb2c695181dff6e26.tljzshvwok.acm-validations.aws
      press ‘continue’ to finish the wizard
  • The state will be pending, but after a while this will be ‘issued’.

Step 2: Create an S3 bucket to store the web pages

  • Open S3 Management Console
  • Create a new bucket
    • Bucket name: example.vdzon.com
    • Ignore all other settings, press next until finished
  • In the ‘Properties page’ of the bucket: click on the ‘Static Website Hosting’ button and select ‘Use this bucket to host a website’, use ‘index.html’ as the index page and press save.
  • Open : permissions/bucket-policy and use the following value:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.vdzon.com/*"
}
]
}
  • Upload an index.html by dropping it on the ‘overview’ page

The page is now visible (but still without https) at:
http://example.vdzon.com.s3-website.eu-central-1.amazonaws.com/index.html

Step 3: Enable https access:

  • Open the AWS cloudfront Console
  • Create distribution
    • use web delivery
    • Origin Domain Name : example.vdzon.com.s3.amazonaws.com
    • Viewer Protocol Policy : Redirect HTTP to HTTPS
    • Alternate Domain Names : example.vdzon.com
    • Choose: “custom SSL certificate” and select the certificate that was created before
    • Default root object: index.html
    • click on ‘create distribution’
  • Check the status of the distribution, it may take a long time before the status is ‘Deployed’
  • Open the distribution, check the “General” details and search the ‘Domainname’ (e.x. dh7qusawd34pw.cloudfront.net), this is needed for the next step

Step 4: Use a custom domain name:

  • Create a DNS entry in your own DNS service provider
    • DNS Name: example.vdzon.com
    • Type: CNAME
    • Value: dh7qusawd34pw.cloudfront.net (this is the Domainname as found in the previous step)

Step 5: Test the static website:
The webpage should now be visible at:
https://example.vdzon.com/

Step 6: Use aws cli to sync a local folder to S3:

using-the-aws-commandline-tools/

https://vdzon.wordpress.com/2018/09/17/

 


source: https://medium.com/@maciejtreder/custom-domain-in-aws-api-gateway-a2b7feaf9c74

Een gedachte over “Hosting a static (https) web site on S3 using a custom domain name

Reacties zijn gesloten.