DEV Community

Cover image for Launching My Landing Page on AWS with SSL (from local environment to live)
Favour Onyeneke
Favour Onyeneke

Posted on

Launching My Landing Page on AWS with SSL (from local environment to live)

Setting Up My Landing Page Using AWS and Apache2 with SSL

Table of Contents

  1. Introduction
  2. Step 1: Setting Up the AWS EC2 Instance
  3. Step 2: Installing Apache2 Web Server
  4. Step 3: Securing the Landing Page with SSL
  5. Step 4: Optimizing and Finalizing
  6. Conclusion

Introduction

In my journey as a cloud engineering student, mainly while working on my exam project, I set out to launch a fully functional and secure landing page. Leveraging the power of AWS and the versatility of Apache2, I built and deployed the page with SSL encryption to ensure security. Here's a detailed walkthrough of how I accomplished this.


Step 1: Setting Up the AWS EC2 Instance

The foundation of my landing page was an AWS EC2 instance. Here’s how I set it up:

Launch an Instance

  • Logged into the AWS Management Console.
  • Navigated to the EC2 service and selected "Launch Instance."
  • Chose an Amazon Linux 2 AMI for its compatibility and lightweight nature.
  • Selected a t2.micro instance, sufficient for a simple landing page and within AWS Free Tier limits.

Configure Security Group

  • Allowed inbound traffic on ports 22 (SSH), 80 (HTTP), and 443 (HTTPS).
  • This ensured I could access the instance securely and serve web traffic.

Connect to the Instance

  • Used SSH to connect to the instance using a terminal:
  ssh -i my-key.pem ec2-user@44.203.122.163
Enter fullscreen mode Exit fullscreen mode

Step 2: Installing Apache2 Web Server

Once connected to the EC2 instance, I installed and configured Apache2:

Install Apache

  • Ran the following commands to install and start Apache:
  sudo apt update -y
  sudo apt install apache2 -y
  sudo systemctl start apache2
  sudo systemctl enable apach2
Enter fullscreen mode Exit fullscreen mode

Deploy the Landing Page Files

  • Created my landing page folder using "mkdir" then project name
  • Copied my repository link from github
  • Used the wget command to download the repo, copied the zip link
  • Installed unzip to extract the main.zip folder
  • Moved all the contents in the folder to /var/www/html/

If your project isn't pushed to github yet, use this instead

  • Upload HTML, CSS, and JavaScript files to the /var/www/html/ directory using SCP:
  scp -i my-key.pem index.html ec2-user@44.203.122.163:/var/www/html/
Enter fullscreen mode Exit fullscreen mode

Verify that the page is accessible via the instance's public IP address.

Search your IP address on any browser and your page should come up or you can search your custom domain name if you've configured it.


Step 3: Securing the Landing Page with SSL

To enhance security, I configured SSL using Let's Encrypt:

Install Certbot

  • Added the EPEL repository and installed Certbot:
  sudo amazon-linux-extras enable epel
  sudo yum install certbot python3-certbot-apache -y
Enter fullscreen mode Exit fullscreen mode

Obtain an SSL Certificate

  • Generated and installed the SSL certificate with Certbot:
  sudo certbot --apache
Enter fullscreen mode Exit fullscreen mode
  • Followed the interactive prompts to select my domain and automatically configure Apache for HTTPS.

Test SSL Configuration

  • Verified the SSL certificate was active by visiting the page using https://<domain>.
  • Used online tools like SSL Labs to ensure the certificate was installed correctly.

Automate Certificate Renewal

  • Scheduled a cron job to renew the certificate automatically:
  sudo crontab -e
Enter fullscreen mode Exit fullscreen mode

Added the following line:

  0 0 * * * certbot renew --quiet
Enter fullscreen mode Exit fullscreen mode

Step 4: Optimizing and Finalizing

With the landing page live and secured, I took additional steps:

Enhance Performance

  • Enabled Gzip compression in Apache to improve page load times.
  • Configured caching headers to optimize content delivery.

Set Up a Custom Domain

  • Configured a domain in Route 53 and pointed it to the EC2 instance’s public IP address.
  • Updated the Apache configuration to handle requests for the custom domain.

Monitor and Maintain

  • Set up AWS CloudWatch to monitor server performance and uptime.
  • Periodically reviewed logs in /var/log/httpd/ for any issues.

Click here to view the project with its documentation https://github.com/onlyfave/AltSchool-Exam-Project

Conclusion

Launching a landing page using AWS and Apache2 with SSL was an incredible learning experience. It helped to solidify my understanding of web server configuration, security best practices, and cloud infrastructure management. By following these steps, I not only met the requirements for my project but also gained practical skills that are invaluable in cloud engineering.

I hope this walkthrough inspires and guides you on your own cloud projects. The combination of AWS, Apache2, and SSL makes it possible to efficiently create secure and scalable web solutions.

Top comments (0)