NGINX CONFIGURATION | DevOps 0


Introduction
As part of the HNG DevOps Stage 0 internship task, I was required to install and configure the NGINX web server on a fresh Ubuntu server. The goal was to serve a custom HTML page displaying the message:
Welcome to DevOps Stage 0 - [Your Name]/[SlackName]
This task tested my ability to work with web server configurations, manage an Ubuntu server, and ensure that the deployed page was accessible via a public IP.
Step-by-Step Approach
1. Setting Up the Server
I started by provisioning an Ubuntu server on a cloud platform. I used DigitalOcean, but you can also use AWS, Linode, Google Cloud, or any other provider.
To connect to the instance, I used SSH:
ssh username@[my-server-ip-address]
2. Installing NGINX
After logging into the server, I updated the package lists and installed NGINX:
sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
Then, I started and enabled the NGINX service to run on system startup:
sudo systemctl start nginx
sudo systemctl enable nginx
To confirm that NGINX was running, I checked its status:
sudo systemctl status nginx
I also tested it by opening http://<your-server-ip>/
in a web browser, which displayed the default NGINX welcome page.
3. Configuring the Custom HTML Page
To meet the task requirements, I modified the default HTML file located at /var/www/html/index.html
.
I edited the file:
sudo vim /var/www/html/index.html
And replaced its contents with:
<html>
<head>
<title>Welcome to DevOps Stage 0</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 - [Asaolu James]/[Jybium]</h1>
</body>
</html>
I saved the file (CTRL + X
, then Y
, then Enter
) and ensured the changes took effect.
Next, I tested the NGINX configuration:
sudo nginx -t
If the test was successful, I reloaded NGINX:
sudo systemctl reload nginx
Finally, I accessed http://<your-server-ip>/
in my browser, and it correctly displayed my custom message.
Challenges Faced and How I Overcame Them
1. Firewall Issues
Initially, I couldn’t access my NGINX server from the browser. The issue was that port 80 (HTTP) was blocked. To fix this, I allowed HTTP traffic:
sudo ufw allow 'Nginx HTTP'
sudo ufw enable
This resolved the issue.
2. Permission Errors
At one point, I encountered a permission error when editing /var/www/html/index.html
. I resolved it by using sudo
while editing the file.
How This Task Contributed to My Learning
This task helped me understand:
Web server configuration: Setting up and managing NGINX.
Linux server management: Installing software and troubleshooting errors.
It reinforced my ability to work with cloud infrastructure, an essential skill for DevOps Engineers.
Additionally, this task aligns with roles such as:
Conclusion
Completing this task was a valuable experience that strengthened my understanding of NGINX, Ubuntu, and cloud deployment. Overcoming challenges like firewall issues and permission errors helped reinforce troubleshooting skills.
With this foundation, I look forward to exploring CI/CD pipelines, and infrastructure automation in future stages.
Let me know if you found this helpful, and feel free to ask any questions!
Subscribe to my newsletter
Read articles from James Asaolu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
