Introduction
As part of the HNG DevOps internship program, I was tasked with configuring NGINX on a fresh Ubuntu server to serve a custom HTML page. This exercise tested my ability to set up a basic web server and reinforced my understanding of cloud infrastructure. Let me share my journey with you.
My Approach
The task initially seemed straightforward: set up an NGINX web server on AWS to serve a custom HTML page. However, it quickly became apparent that this project would teach me valuable lessons about system administration and web server configuration.
Here's how I broke down the task:
Infrastructure Setup
I started by launching an Ubuntu-based EC2 instance on AWS. The steps included:
Choosing an Ubuntu 24.04 LTS AMI (Free Tier eligible).
Selecting a t2.micro instance (Free Tier eligible).
Creating a security group to allow SSH (port 22) and HTTP (port 80) access from anywhere (0.0.0.0/0).
Generate an SSH key pair to connect to my instance securely.
Connecting to the Instance and NGINX Installation and Configuration
After launching the EC2 instance, I used SSH to connect:
chmod 400 your-key-pair.pem
ssh -i your-key-pair.pem ubuntu@your-instance-public-ip
Then, I updated the system and installed and configured NGINX:
# Update package list
sudo apt update
# Install NGINX
sudo apt install nginx -y
# Verify NGINX is running
sudo systemctl status nginx
Configuring the Custom HTML Page
Next, I replaced the default index.html file with my custom page:
sudo tee /var/www/html/index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>DevOps Stage 0</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #f0f2f5;
}
.message {
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="message">
<h1>Welcome to DevOps Stage 0 - [Your Name]/[SlackName]</h1>
</div>
</body>
</html>
EOF
Testing the Setup
I tested the NGINX configuration:
sudo nginx -t
I restarted NGINX:
sudo systemctl restart nginx
I opened a web browser and entered http://ec2-public-ip/, confirming that my custom message was displayed.
Challenges and Solutions
I encountered permission errors. Which I fixed allowing the appropriate permissions:
# Set correct ownership and permissions
sudo chown www-data:www-data /var/www/html/index.html
sudo chmod 644 /var/www/html/index.html
How This Task Contributes to My Learning and Career Goals
Completing this task reinforced my understanding of cloud infrastructure, networking, and server administration. It was an essential step in my journey toward becoming a DevOps Engineer. By working hands-on with AWS and NGINX, I improved my troubleshooting skills and deepened my knowledge of cloud-based deployments. This experience also aligns with my long-term goal of mastering cloud automation and infrastructure management.
Conclusion
This experience gave me practical insights into server provisioning, firewall management, and web server configuration. The ability to set up a web server from scratch is a fundamental skill for Cloud Engineers and DevOps professionals. Moving forward, I plan to explore more advanced topics like load balancing, auto-scaling, and CI/CD pipelines.
Top comments (0)