Setting up an EC2 with https

Setting up an EC2 with https

Introduction

Setting up an EC2 with https is a bit tricky. This article will guide you through the process.

Prerequisites

  • You have a domain name
  • You have an EC2 instance running

Make sure that the security groups are set to allow traffic on the ports you want to use in the EC2.

Step 1 - Create a certificate

  1. Go to the AWS Certificate Manager
  2. Click on Request a certificate and Request a public certificate
  3. Add your domain name and click Next
  4. Select DNS validation and click Next
  5. Click Confirm and request
  6. Add the cname record to your DNS provider

Step 2 - Create A Target Group

  1. Go to the EC2 console
  2. Click on Target Groups
  3. Click on Create target group
  4. Add a name and click Next
  5. Select Instance and click Next
  6. Select your EC2 instance and click Next
  7. Click Next
  8. Click Create target group

The most important step:

Make sure that the port is the port that your server is running on in EC2. If you don't set this correctly, you will get a 502 error.

Step 3 - Create a Load Balancer With an HTTPS Listener

  1. Go to the EC2 console
  2. Click on Load Balancers
  3. Click on Create Load Balancer
  4. Select Application Load Balancer and click Create
  5. Add a name and click Next
  6. Select your VPC and click Next
  7. Select the target group you created in step 2 and click Next
  8. The certificate should be in the dropdown if the CNAME's were added correctly. Select it and click Next
  9. Click Next

Step 6 - Add the DNS records

  1. Go to the EC2 console
  2. Click on Load Balancers
  3. Click on your load balancer
  4. Copy the DNS name
  5. Go to your DNS provider and add a CNAME record with the DNS name as the value
  6. The CNAME name should be the domain or subdomain you want to use that the certificate was created for
  7. Wait for the DNS to propagate
  8. Enjoy your https website

Donations accepted at: xsimon.eth