DEV Community

Cover image for Setting Up an NGINX Web Server on Azure: My DevOps Stage 0 Experience
Chinaza Otumba
Chinaza Otumba

Posted on

Setting Up an NGINX Web Server on Azure: My DevOps Stage 0 Experience

Introduction

As part of the HNG DevOps internship, I completed Stage 0: NGINX Configuration by installing and configuring an NGINX web server on an Ubuntu machine. This blog post provides a guide, detailing my approach, challenges faced, solutions implemented, and key takeaways from this task.

Task Overview

The objective of this task was to:

  1. Install and configure NGINX on an Ubuntu server.
  2. Replace the default NGINX page with a custom HTML file displaying: Welcome to DevOps Stage 0 - [Your Name]/[SlackName]
  3. Ensure the page is accessible via a public IP address.

Step-by-Step Approach

1️⃣ Setting Up the Ubuntu Server on Azure

Since the task required a fresh Ubuntu instance, I deployed an Ubuntu 22.04 virtual machine on Microsoft Azure following these steps:

  • Logged into the Azure Portal.
    Azure portal

  • Navigated to Virtual Machines and selected Create > Azure Virtual Machine.

Virtual machine

  • Selected Ubuntu 22.04 LTS as the OS and Configured the machine.

Creating virtual machine in azure portal

  • Configured Inbound Port Rules, initially allowing only SSH (port 22), which later caused accessibility issues.

inbound port

  • After deployment, copied the Public IP Address and connected via SSH:
   ssh username@my-server-ip
Enter fullscreen mode Exit fullscreen mode

2️⃣ Updating the System

Before installing any software, I updated the system to ensure the latest security patches and package versions:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

system update

3️⃣ Installing NGINX

To install and verify NGINX:

sudo apt install nginx -y
sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

If the service isn't running, start it manually but in case I didn't need to do this:

sudo systemctl start nginx
Enter fullscreen mode Exit fullscreen mode

To ensure NGINX starts automatically at boot, enable the service:

sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

NGINX status

4️⃣ Configuring the Custom Web Page

To meet the task requirements, I modified the index.html file:

sudo nano /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Replaced the default content with:

<!DOCTYPE html>
<html>
<head>
    <title>Welcome</title>
</head>
<body>
    <h1>Welcome to DevOps Stage 0 - [Your Name]/[SlackName]</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

After saving the file, I restarted NGINX:

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

custom html

5️⃣ Configuring Inbound Port Rules on Azure

Initially, I couldn't access the web page due to inbound rule restrictions. I resolved this by allowing HTTP (port 80) traffic.

Using the Azure Portal:

  1. Navigated to Virtual Machines > Selected my VM > Networking > Network settins.
  2. Clicked Create port rule.
  3. Set Destination Port to 80, Protocol to TCP, and Action to Allow.
  4. Save the changes.

port rule

6️⃣ Testing the Web Page

I confirmed the setup by opening a browser and visiting:

http://my-server-ip:80
Enter fullscreen mode Exit fullscreen mode

The custom message successfully displayed, indicating a successful configuration.

custom HTML on browser

Challenges & Solutions

🔴 Challenge 1: Choosing the Right Server and Public IP Availability

issue: The first challenge I faced was deciding which server to use for this project. Initially, I considered using my Raspberry Pi, but I encountered difficulties with obtaining a stable public IP address due to ISP restrictions.

Solution: To overcome this, I opted for Microsoft Azure, which provides a reliable public IP by default, ensuring seamless deployment and accessibility.

🔴 Challenge 2: Configuring Inbound Ports on Azure

Issue: I initially allowed only SSH traffic, preventing access to NGINX.

Solution: I modified the network security group settings to allow inbound traffic on port 80 via both the Azure portal and CLI.

Port rule

Key Takeaways

This project provided invaluable hands-on experience with:

  • Cloud Infrastructure: Setting up an Ubuntu VM on Azure.

  • Linux Server Management: Handling SSH connections and package management.

  • Web Server Configuration: Installing and managing NGINX.

  • Networking & Security: Configuring inbound rules to allow web traffic.

  • Troubleshooting: Debugging issues related to firewall rules and NGINX status.

How This Task Helps My DevOps Journey

Completing this task gave me practical experience in Linux system administration, networking, and troubleshooting—fundamental DevOps skills. I also improved my ability to document configurations and resolve real-world deployment challenges.

Conclusion

This experience improved my ability to set up, configure, and troubleshoot web servers while reinforcing best practices for cloud security and networking. Looking forward to more HNG tasks! 💪

Looking to Hire?

Find top-tier engineers at HNG:

Top comments (0)