Setting Up an NGINX Web Server on Azure: My DevOps HNG 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: Install and configure NGINX on an Ubuntu server. Replace the default NGINX page with a custom HTML file displaying: Welcome to DevOps Stage 0 - [Your Name]/[SlackName] 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. Navigated to Virtual Machines and selected Create > Azure Virtual Machine. Selected Ubuntu 22.04 LTS as the OS and Configured the machine. Configured Inbound Port Rules, initially allowing only SSH (port 22), which later caused accessibility issues. After deployment, copied the Public IP Address and connected via SSH: ssh username@my-server-ip 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 3️⃣ Installing NGINX To install and verify NGINX: sudo apt install nginx -y sudo systemctl status nginx If the service isn't running, start it manually but in case I didn't need to do this: sudo systemctl start nginx To ensure NGINX starts automatically at boot, enable the service: sudo systemctl enable nginx 4️⃣ Configuring the Custom Web Page To meet the task requirements, I modified the index.html file: sudo nano /var/www/html/index.html Replaced the default content with: Welcome Welcome to DevOps Stage 0 - [Your Name]/[SlackName] After saving the file, I restarted NGINX: sudo systemctl restart nginx 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: Navigated to Virtual Machines > Selected my VM > Networking > Network settins. Clicked Create port rule. Set Destination Port to 80, Protocol to TCP, and Action to Allow. Save the changes. 6️⃣ Testing the Web Page I confirmed the setup by opening a browser and visiting: http://my-server-ip:80 The custom message successfully displayed, indicating a successful configuration. Challenges & Solutions

Feb 3, 2025 - 05:09
 0
Setting Up an NGINX Web Server on Azure: My DevOps HNG 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

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

system update

3️⃣ Installing NGINX

To install and verify NGINX:

sudo apt install nginx -y
sudo systemctl status nginx

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

sudo systemctl start nginx

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

sudo systemctl enable nginx

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

Replaced the default content with:




    </span>Welcome<span class="nt">


    

Welcome to DevOps Stage 0 - [Your Name]/[SlackName]

After saving the file, I restarted NGINX:

sudo systemctl restart nginx

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

The custom message successfully displayed, indicating a successful configuration.

custom HTML on browser

Challenges & Solutions