π Introduction
As part of the HNG DevOps Stage 0 challenge, I successfully deployed an NGINX web server on a fresh Ubuntu machine using an Azure Virtual Machine (VM). Unlike my initial Vagrant-based deployment, this approach ensures full-time availability and public accessibility over the internet.
This blog post documents the full process, challenges faced, and how I overcame them.
1οΈβ£ Setting Up the Environment
π₯οΈ Prerequisites
Before getting started, ensure you have the following:
βοΈ An Azure Account (for deploying the VM)
βοΈ SSH Client (for connecting to the VM)
βοΈ A basic understanding of NGINX and Ubuntu
2οΈβ£ Creating the Azure Virtual Machine (VM)
1οΈβ£ Go to Azure Portal and create a new Ubuntu 20.04 LTS VM.
2οΈβ£ Choose the right instance type (Standard B1s is a good starting point).
3οΈβ£ Enable SSH login and allow HTTP (port 80) traffic.
4οΈβ£ Assign a Public IP Address for remote access.
5οΈβ£ Deploy the VM and connect via SSH:
ssh <username>@102.37.154.154
3οΈβ£ Installing and Configuring NGINX
After logging into the Azure VM, I installed NGINX with:
sudo apt update -y
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
To confirm NGINX was running, I checked its status:
sudo systemctl status nginx
βοΈ Result: "Active (running)" β
4οΈβ£ Creating the Custom Welcome Page
Next, I customized the default NGINX page by modifying /var/www/html/index.html
:
echo '<html>
<head>
<title>Welcome</title>
<style>
body { display: flex; justify-content: center; align-items: center; height: 100vh; font-family: Arial, sans-serif; }
h1 { text-align: center; }
</style>
</head>
<body>
<h1>Welcome to DevOps Stage 0 - Rowland Adimoha/Rowjay</h1>
</body>
</html>' | sudo tee /var/www/html/index.html > /dev/null
Then, I restarted NGINX to apply the changes:
sudo systemctl restart nginx
Now, my website was ready to be accessed via the public IP!
5οΈβ£ Configuring Azure Firewall for Public Access
By default, Azure blocks port 80. To allow external access, I had to update the Network Security Group (NSG):
1οΈβ£ Go to Azure Portal β Virtual Machine β Networking.
2οΈβ£ Add an inbound rule:
- Source: Any
- Source Port Ranges: *
- Destination: Any
- Service: Custom
- Destination Port Ranges: 80
- Protocol: TCP
- Action: Allow
- Priority: 310 3οΈβ£ Save the rule, and my site became accessible from anywhere on the internet at:
6οΈβ£ Testing the Deployment
πΉ Browser Test: Visiting http://102.37.154.154 displayed:
"Welcome to DevOps Stage 0 - Rowland Adimoha/Rowjay"
πΉ NGINX Header Check:
I confirmed my server was serving requests properly:
curl -I http://102.37.154.154
βοΈ The response contained "Server: nginx", confirming that NGINX was active.
πΉ Verifying Uptime:
I ran:
sudo systemctl status nginx
βοΈ NGINX was running without errors. β
π Challenges Faced & Solutions
β Issue 1: Website Not Loading Externally
Problem: After configuring NGINX, I could access the site locally but not from other devices.
Solution: The issue was port 80 being blocked in Azure NSG. After adding an allow rule for port 80, the site became publicly accessible.
β Issue 2: NGINX Not Restarting After Reboot
Problem: NGINX didnβt automatically restart after VM reboots.
Solution: I ran:
sudo systemctl enable nginx
βοΈ This ensured NGINX starts automatically on boot.
π― Lessons Learned & How This Contributes to My DevOps Growth
π‘ 1. Cloud Infrastructure Management
This task helped me understand Azure VM deployment and network configurations for web applications.
π‘ 2. Debugging & Troubleshooting Network Issues
I learned how to troubleshoot cloud firewall rules to enable public access.
π‘ 3. Web Server Automation
I automated NGINX installation and web page deployment using shell scripts.
π References (Cited Properly)
As I continue on this DevOps journey, I look forward to exploring career opportunities in the field. If you're looking for skilled DevOps Engineers, check out:
Top comments (0)