Introduction
In this blog post, I share my experience with the DevOps Stage 0 - NGINX Configuration task. This task required me to set up and configure NGINX on a fresh Ubuntu server, serving a custom HTML page as the default page.
My Approach:
To complete this task, I followed this step-by-step approach:
Step 1: Create an AWS EC2 Instance
- Log in to the AWS Management Console.
- Navigate to the EC2 dashboard.
- Click "Launch Instance" and choose "Ubuntu Server 24.04 LTS (HVM), SSD Volume Type" as Amazon Machine Image .
- Choose the “t2.micro” instance type.
- Create a new key pair (I named mine “hng12” and left other options as default).
- Download and save the .pem file in a secure and accessible directory.
- Create a new security group and allow inbound SSH and HTTP traffic from all sources (0.0.0.0/0)
- Leave all other options as is and Launch the instance.
Step 2: Install NGINX
- Connect to the EC2 instance using the “EC2 Instance Connect” option.
- Update the package list: sudo apt update
- Install NGINX: sudo apt install nginx
- Verify NGINX installation: nginx -v
Step 3: Configure NGINX
- Create a new file in the /var/www/html/ directory: sudo nano /var/www/html/index.html
- Add the following HTML code to the file:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to DevOps Stage 0</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 - Kemdirim Njoku/Kemystery</h1>
</body>
</html>
Replace [Kemdirim Njoku] and [Kemystery] with your actual name and Slack username.
- Open the NGINX configuration file: sudo nano /etc/nginx/sites-available/default
- Confirm that the content of the configuration file is serving the custom HTML page:
`server {
listen 80;
server_name _;
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}`
- Restart NGINX to apply the changes: sudo service nginx restart
Step 5: Test the Configuration
- Get the public IP address of the EC2 instance. In my case: 44.212.56.112
- Access the public IP address in a web browser: http://44.212.56.112/
- Verify that the custom HTML page is displayed with the correct message.
Challenges and Solutions
During this task, I encountered a few challenges:
- NGINX configuration: I had to learn about NGINX configuration files and how to update them to serve a custom HTML page.
- HTML syntax: I had to ensure that the HTML code I wrote was correct and would display the message as expected.
To overcome these challenges, I:
- Referenced online documentation: I consulted the official NGINX documentation and other online resources to learn about NGINX configuration files.
- Used online HTML validators: I used online HTML validators to ensure that my HTML code was correct and would display the message as expected.
Conclusion
Completing this task helped me gain hands-on experience with NGINX configuration and HTML syntax. I learned how to set up and configure NGINX on a fresh Ubuntu server, serving a custom HTML page as the default page.
This task contributes to my learning and professional goals by:
Improving my DevOps skills: I gained experience with NGINX configuration, which is an essential skill for DevOps engineers.
Enhancing my problem-solving skills: I learned how to overcome challenges and debug issues during the task.
Hire experienced DevOps Engineers here
Hire experienced Cloud Engineers here
Top comments (0)