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
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 toTCP
, and Action toAllow
. - 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.