Setting up an AWS Application Load Balancer with EC2 and enabling SSL on a Web Server

Running a highly scalable web server on AWS with SSL

Amazon Web Services (AWS) provides a scalable and highly available platform to host web applications. One of the services provided by AWS is the Application Load Balancer (ALB) that can distribute incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses. In this tutorial, we will cover how to set up an ALB, an EC2 instance, and how to secure the connection to the web server with SSL.

Step 1: Create an EC2 instance

  1. Open the AWS Management Console.
  2. Go to the EC2 dashboard.
  3. Click on the "Launch Instance" button.
  4. Choose the Amazon Linux AMI and select the instance type.
  5. Configure the instance settings as desired, then proceed to the next step.
  6. Add storage to the instance as needed and configure the security group to allow incoming HTTP traffic on port 80.
  7. Launch the instance.

Step 2: Install a web server on the EC2 instance

  1. Connect to the EC2 instance using SSH.
  2. Install the Apache web server by running the following command:
    sudo yum install httpd -y
  3. Start the Apache service by running the following command:
    sudo systemctl start httpd
  4. Verify that the Apache service is running by visiting the public IP address of the EC2 instance in a web browser.

Step 3: Create an Application Load Balancer

  1. Go to the EC2 dashboard.
  2. Click on the "Load Balancers" menu option.
  3. Click on the "Create Load Balancer" button.
  4. Select the "Application Load Balancer" option and click on the "Create" button.
  5. Give the load balancer a name, select the appropriate VPC, and configure the listeners as desired.
  6. Choose the availability zones to host the ALB, then proceed to the next step.
  7. Add the EC2 instance as a target, then click on the "Create" button.

Step 4: Secure the connection with SSL

  1. Obtain an SSL certificate for your domain, either by purchasing one from a certificate authority or by using AWS Certificate Manager to generate a free certificate.
  2. Upload the SSL certificate to the ALB.
  3. In the EC2 dashboard, go to the Load Balancer section, click on the ALB you created and navigate to the "Listeners" tab.
  4. Click on the HTTPS listener and select the SSL certificate.
  5. Save the changes.

Step 5: Verify the setup

  1. Visit the DNS name or public IP address of the ALB in a web browser, using the HTTPS protocol.
  2. Verify that the SSL certificate is valid and that the connection is secure.
  3. Verify that the ALB is routing traffic to the EC2 instance and that the web server is accessible.

With these steps, you should have a fully functional Application Load Balancer with an EC2 instance and SSL enabled. You can now customize and configure the web server and the ALB as desired to fit your requirements.

Launch a Web App on AWS

Sign in to leave a comment
Adding a Favicon to a WordPress Site without a Plugin
Add a custom Favicon to a running WordPress website with no plugins