Setting Up CloudFront to Serve HTTPS Requests for kbt-Documentation Using Amazon S3 Bucket

Introduction

This document provides a detailed guide on how to configure Amazon CloudFront to serve HTTPS requests for the kbt-Documentation hosted in an Amazon S3 bucket. HTTPS ensures secure communication between the client and the server, encrypting the data in transit.

Prerequisites

  • An Amazon S3 bucket containing the kbt-Documentation files using Antora.

  • An AWS account with necessary permissions to configure CloudFront and S3.

  • A registered domain name (e.g., example.com) using Amazon Route 53 or any other domain registrar.

Steps

Step 1: Create an Amazon S3 Bucket

  1. Log in to the AWS Management Console.

  2. Navigate to Amazon S3 service.

  3. Create a new S3 bucket named docs.kanilebettu.in.

  4. Upload your website files to the bucket using Antora.

Step 2: Configure S3 Bucket for Website Hosting

  1. Select the docs.kanilebettu.in bucket.

  2. Go to the "Properties" tab.

  3. Choose "Static website hosting."

  4. Select "Use this bucket to host a website."

  5. Set the index document to index.html or your preferred default file.

  6. Save the changes.

Refer this page to achive setup setp 1 and setp 2 Host a Static Website using S3 bucket.

s3 bucket public

Step 3: Create an SSL Certificate in AWS Certificate Manager

  1. Open AWS Certificate Manager service.

  2. Request a new public certificate for your domain name (e.g., example.com).

  3. Complete the validation process for the certificate.

acm virginia

Step 4: Create a CloudFront Distribution

Go to the Amazon CloudFront Service:

  • Open the AWS Management Console.

  • Navigate to the Amazon CloudFront service by searching for "CloudFront" in the AWS services search bar.

cloud front search

Click "Create Distribution":

  • In the CloudFront dashboard, click the "Create Distribution" button to initiate the setup of a new CloudFront distribution.

create distribute

Configure the Origin Settings:

create distribution
  • Origin Domain Name: Set the Origin Domain Name to the endpoint of your Amazon S3 bucket where your website content is stored (e.g., kbt-Documentation.s3.amazonaws.com). CloudFront will fetch content from this S3 bucket.

  • Origin Path (Optional): If your files are stored in a specific directory within the S3 bucket, specify the path here.

Ensure that your S3 bucket permissions are correctly configured to allow CloudFront to access the objects.

Configure OAC(origin access control) for secure connection:

  • In the Origin configuration section, select an S3 origin from the Origin domain drop-down list.

cloud front image2
  • if you are not created OAC click Create Contorl Setting and select s3 bucket

create oac cloudfront

you will get policy later on after create Distribution i will let you on that point.

you must copy update the policy to s3 bucket for secure connection.

Configure Default Cache Behavior:

  • Set other options like "Viewer Protocol Policy" to "Redirect HTTP to HTTPS" to enforce HTTPS for secure communication between clients and CloudFront.

cache behavior cloud front

Alternate domain name (CNAME) with CloudFront:

  • For Alternate Domain Names (CNAMEs), choose Add item, and then enter your alternate domain name.

  • For Custom SSL Certificate, choose the custom SSL certificate from the dropdown list that covers your CNAME to assign it to the distribution.

coustom dominname cloudfront
For more information on installing a certificate, see How do I configure my CloudFront distribution to use an SSL/TLS certificate?

Review and Create:

  • Review all the settings to ensure they are accurate.

  • Click the "Create Distribution" button to create the CloudFront distribution.

policyfors3bucket
  • you need to copy policy and past in to s3 bucket Permissions tab here this policy will allow to access only from cloud front distribution.

s3 bucket permission docs

Wait for Distribution Deployment:

  • CloudFront may take some time to deploy the distribution and propagate the changes globally. Monitor the CloudFront dashboard until the distribution status changes to "Deployed."

deploy destribution

Note Down CloudFront Domain Name:

  • Once deployed, note down the CloudFront domain name (e.g., d12345abcdef.cloudfront.net). This domain will be used to access your website via CloudFront.

Always ensure that you secure your CloudFront distribution and AWS resources with appropriate access controls and permissions.

Step 5: Update DNS Records:

  • Be sure to update the DNS for your domain to a CNAME record that points to the CloudFront distribution’s provided domain. You can find your distribution’s domain name in the CloudFront console.

  • If you use Amazon Route 53 as your DNS provider, then see Configuring Amazon Route 53 to route traffic to a CloudFront distribution.

  • If you use another DNS provider, then you can create a CNAME record (www.example.com CNAME d111111abcdef8.cloudfront.net) to point to the distribution’s domain.

route53 cloudfront
DNS standards require that an apex domain (example.com) use an authoritative (A) record that maps to an IP address. You can point your apex domain to your CloudFront distribution only if you’re using Route 53. If you’re using another DNS provider, then you must use a subdomain (www.example.com).

Step 6: Check your DNS Name :

Click the below link to get kbt-Documentation.
https://docs.kanilebettu.in

finaloutput docs