Deploying a Custom HTML Homepage with NGINX on Ubuntu in AWS

Deploying a Custom HTML Homepage with NGINX on Ubuntu in AWS

Introduction

As part of my DevOps learning journey, I recently completed a task to deploy a custom HTML homepage using NGINX on an Ubuntu server hosted on AWS. The goal was to set up and configure NGINX on a fresh Ubuntu server to serve a default page located at /var/www/html/index.html, featuring a personalized message.

For this task, I utilized AWS EC2 instance, which proved to be an ideal choice due to its scalable and flexible compute capacity. EC2 allows for quick deployment and efficient management of cloud applications, eliminating the need for physical hardware. With EC2, I was able to customize the instance’s performance based on specific requirements such as CPU, memory, storage, and networking, ensuring optimal resource allocation. Additionally, EC2’s scalability allowed me to easily adjust resources based on demand, making it perfect for dynamic workloads. Its integration with other AWS services, coupled with robust security and monitoring features, reinforced EC2’s reliability as a solution for hosting and running cloud applications.

This task not only enhanced my hands-on experience with web server setup and configuration, Linux administration, and cloud infrastructure management but also provided valuable insights into troubleshooting and overcoming challenges. Come with me as I walk you through the process followed to complete this task and how I successfully resolved blockers encountered along the way.

Approach to Accomplishing the Task

To successfully complete this task, I used the tools outlined below and followed a 5 -step structured approach:

Tools Used

  • AWS account: To create a free AWs account, click Create an AWS Account.

  • Visual Studio Code for terminal. Download and Install from the official website.

  • Git. Download and install from official website

Step 1: Setting Up the AWS EC2 Instance

Launch an Ubuntu Server instance on AWS:

  • Log in to your AWS Management Console.

  • Navigate to EC2 Dashboard → Click Launch Instance.

  • Select an Ubuntu 22.04 LTS AMI.

  • Configure a t2.micro instance (suitable for free-tier users).

  • Set up a security group for inbound rules.

    • Allow HTTP (80) from anywhere (0.0.0.0/0).

    • Allow SSH (22) from your IP for security.

Step 2: Updating the System and Installing Nginx

  • Connect to the instance via SSH on the terminal

  • Install and configure NGINX: Use the following commands

sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y

  • Verify the installation.

      nginx -v
    

  • Start and enable Nginx.

sudo systemctl start nginx
sudo systemctl enable nginx

  • Ensure NGINX service is running.
sudo systemctl status nginx

Step 3: Accessing Nginx from a Browser

Step 4: Creating a Custom HTML Page

  • Edit the default NGINX homepage to display my personalized message:
sudo nano /var/www/html/index.html
  • Add the custom HTML content and saved:
<!DOCTYPE html>
<html>
<head>
    <title>DevOps Stage 0</title>
</head>
<body>
    <h1>Welcome to DevOps Stage 0 - Celestina Odili/FavouredTy</h1>
</body>
</html>
  • Restart NGINX to apply the changes:
sudo systemctl restart nginx

Step 5: Testing the Configuration

Access the custom html page on a browser using the instance’s public IP:

http://<your-instance-ip>

Challenges and Solutions

  1. http inbound rule configuration conflict

During the instance configuration, I encountered a conflict error when attempting to add HTTP, stating that port 80 already existed even though it was not present. To resolve this, I proceeded with the deployment without specifying port 80. After deployment, I manually edited the inbound rules to include port 80.

  1. Permission Denied

    Initially, I used the PowerShell terminal to connect to the instance's public IP but encountered a Permission Denied error.

    These steps were taken to resolve the issue.

  • I verified that the keypair is located is same directory.

  • I also verified that git is installed.

  • I ensured the correct ownership and permissions using chmod 400 "myKeyPair.pem".

  • Finally, I switched to bash instead of PowerShell.

Task Contributes to My Knowledge Development and Professional Goals

  • Web Server Deployment: This task enhanced my practical understanding of configuring and managing NGINX, which is essential for deploying web servers efficiently in real-world scenarios.

  • Cloud Infrastructure Management: It strengthened my skills in launching, configuring, and managing AWS EC2 instances, providing me with valuable experience in cloud-based infrastructure setup and management.

  • Troubleshooting Skills: By addressing network and configuration issues, I gained deeper insights into troubleshooting, which is crucial for resolving challenges in cloud environments and ensuring optimal system performance.

  • Linux Administration: This task improved my ability to manage file permissions and system services, essential for maintaining a stable and secure server environment in Linux-based systems.

  • Job Readiness: This experience demonstrates my capability to work with foundational web server configurations and deliver functional web services. Companies hiring for DevOps Engineers or AWS Solutions Architects highly value hands-on experience in these areas, making this task an important step in advancing my career in DevOps. For those aiming for similar roles, it is a good idea to continuously monitor DevOps Engineers and AWS Solutions Architects job openings where these essential skills are needed.

Conclusion

This experience significantly reinforced my ability to deploy and configure a web server in a cloud environment, specifically with AWS EC2 and NGINX. It allowed me to deepen my practical understanding of web server management, cloud infrastructure, and networking. Additionally, the task enhanced my troubleshooting skills, especially in diagnosing and resolving network and configuration issues, which are vital in real-world DevOps and cloud engineering roles. The hands-on experience with Linux administration further strengthened my system management capabilities. Moving forward, I plan to build on this foundation by integrating automated deployment tools like CloudFormation or Terraform. This will streamline the deployment process, enhance scalability, and improve the overall infrastructure management. Gaining expertise in these tools will help me create more efficient and reproducible environments for deploying cloud-based applications. Ultimately, this experience has been an important step in my professional development as I continue to build skills essential for advanced cloud and DevOps roles.