DEV Community

Ursula Okafo
Ursula Okafo

Posted on • Edited on

Setting Up a Simple Web Server on a Fresh Ubuntu Server with NGINX

Introduction

During the DevOps Stage 0 in the HNG Internship, I was tasked with setting up a simple web server using NGINX on an Ubuntu server. This task aimed to test my ability to work with basic web server configurations while ensuring my deployed server was publicly accessible. It sounded straightforward at first, but this task ended up teaching me quite a lot about web servers, Linux, and cloud platforms. Here's a breakdown of my experience, what I learned, and how I did it.

Why I Chose Azure:

For this task, I used an Ubuntu server hosted on Microsoft Azure. The main reason? I’m a new Azure user and received free credits as part of their welcome package. This made Azure a budget-friendly and convenient choice for launching a virtual machine without spending a dime.
Beyond the free credits, Azure provides a clean and beginner-friendly interface, which made it easy to deploy and manage my VM. I was able to get the server up and running quickly, allowing me to focus entirely on learning and configuring NGINX.
Note: You’re not limited to Azure!
This task can be completed using any cloud platform like AWS, Google Cloud Platform (GCP), or even a local virtual machine. The important part is understanding how to work with the server, not where it's hosted.

🔧 What Is NGINX? (Like You’ve Never Heard of It)

If you’re like me before this task, you might be wondering: “What in the world is NGINX?”
Well, NGINX (pronounced "Engine-X") is a powerful and super popular web server. You can think of it like a smart waiter in a restaurant. When someone visits your website, NGINX takes that request, finds the correct page or file, and brings it back to their browser.

But NGINX doesn’t just stop at being a “waiter.” It’s also a:
🖥️ Web server
🔁 Reverse proxy (passes requests to another server)
⚖️ Load balancer (shares traffic across multiple servers)
🔐 SSL handler (helps secure your website)
📦 Cache (speeds things up by storing responses)
It’s lightweight, fast, and used by companies like Netflix, Dropbox, and WordPress. Pretty cool for something I hadn’t heard of before this task!

Getting Started with Azure Virtual Machine(VM)

Setting up a VM on Microsoft Azure was a smooth process. Here’s what I selected during setup:

  • Chose the Ubuntu 22.04 LTS image from the Azure Marketplace.
  • Selected the Standard B1s size (which is eligible for Azure Free Tier).
  • Created a new resource group to organize my resources.
  • Allowed SSH (port 22) and HTTP (port 80) through the network security group (NSG) settings to enable secure access and web traffic.
  • Generated a new SSH key pair to securely connect to the VM from my terminal using the .pem file (or convert to .ppk for PuTTY on Windows).
  • Chose a region closest to me for better latency.
  • Launched the VM and connected to it via SSH to begin configuration.

🛠️ Setting Up NGINX: Steps I Followed

Here’s a summary of how I installed and configured NGINX:

Update Server Packages:

sudo apt update
sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

Image description

Install NGINX:

sudo apt install nginx
Enter fullscreen mode Exit fullscreen mode

Image description

Start and Enable NGINX:

sudo systemctl start nginx
sudo systemctl enable nginx

# Check if Nginx is running
sudo systemctl status nginx

Enter fullscreen mode Exit fullscreen mode

Image description

Test the Setup
I accessed my public IP address:

http://<your-public-ip>/
Enter fullscreen mode Exit fullscreen mode

and confirmed that nginx is rightly configured.

Image description

Create a Custom HTML Page:

echo "Welcome to DevOps Stage 0 - [Your Name]/[SlackName], we are glad to have you" | sudo tee /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Image description
NB: (I replaced [Your Name] and [SlackName] with my actual name and Slack username.)
Access your IP address once more:

http://<your-public-ip>/
Enter fullscreen mode Exit fullscreen mode

And boom — my custom message was live on the web!

Image description

Key Takeaways

This task taught me several important lessons:

✅ How to launch an instance and configure it for web hosting.

✅ Setting up a basic web server using NGINX.

✅ Managing cloud security settings to allow public access.

✅ Troubleshooting connectivity issues related to firewall and inbound rules.

😅 Challenges I Faced

Permission issues: When trying to write to /var/www/html/index.html, I got denied until I added sudo.

🎯 What I Learned

  • This task taught me a lot more than just typing commands:
  • I now understand what a web server does and how to use one.
  • I learned how to use Azure’s cloud platform to host my own VM.
  • I got hands-on with Linux and command-line tools, which are key skills in DevOps.
  • It was also a fun reminder of how small configurations can power big things on the internet.

References

Top comments (2)

Collapse
 
ameh_mathias profile image
Ameh Mathias Ejeh

Nice. Weldon!!

Collapse
 
ursulaonyi profile image
Ursula Okafo

Thank you sir