Introduction
Deploying Nginx on an Azure virtual machine (VM) was a great learning experience that strengthened my understanding of cloud infrastructure, Linux server management, and networking configurations. This blog post details my approach, challenges encountered, solutions applied, and how this task aligns with my professional goals.
Nginx is a web server, meaning it serves web content, handles HTTP requests, and acts as a reverse proxy. Reverse proxy means a server or application that functions as an intermediary between clients and actual web servers, intercepting incoming requests from clients, forwarding them to the appropriate backend server, and then sending the response back to the client.
Also note that Nginx as a web server needs an operating system to run, reason I am deploying it on an Azure Ubuntu VM.
My Approach
Here is a step-by-step breakdown of how I completed the task:
1.Creating an Azure Resource Group and Virtual Machine
The first step was to set up an Azure resource group to keep all project-related metadata organized. Then, I created an Ubuntu-based VM to host my Nginx installation.
2.Connecting to the Azure VM
After deploying the VM, I used the following command to log in to my Azure account from the Ubuntu terminal:
az login
Once authenticated, I established an SSH connection to the VM using:
ssh username@<VM_IP_Address>
3.Updating System Packages
To ensure that my system was up to date, I ran:
sudo apt update && sudo apt upgrade -y
The -y flag automatically confirmed the installation of package updates.
4.Installing Nginx
I installed Nginx using:
sudo apt install nginx -y
5.Starting and Enabling Nginx
Once installed, I started the Nginx service and enabled it to start on boot:
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
A successful installation was confirmed when the output displayed active (running).
6.Verifying Nginx Installation
To verify that Nginx was running correctly, I opened my browser and navigated to
http://<VM_IP_Address>/
I was greeted with the default Nginx welcome page, confirming that the server was working.
7.Customizing the Default Nginx Page
To replace the default Nginx welcome page, I edited the HTML file located at /var/www/html/index.html:
sudo vim /var/www/html/index.html
I replaced the default content with:
<h1>Welcome to DevOps Stage 0 - Uyiosa Praise Oboite/Uyi</h1>
Then, I saved the changes and restarted Nginx to apply them:
sudo systemctl restart nginx
To confirm the update, I reloaded the browser at http:/// and saw my custom message displayed.
Challenges and Resolutions
1.SSH Connection Failure on Port 22
Issue: Initially, I couldn't SSH into the VM because the connection timed out.
Resolution: I updated the VM's Network Security Group (NSG) inbound rules to allow traffic on port 22.
2. Permission Issues When Editing the Nginx HTML Page
Issue: I encountered a permission error when trying to edit /var/www/html/index.html.
Resolution: I used superuser privileges (sudo) before editing the file:
sudo vim /var/www/html/index.html
Key Takeaways
Completing this task reinforced my understanding of:
Cloud infrastructure management using Azure.
Linux system administration (package management, service control, and file editing).
Networking configurations (SSH and NSG rules).
Web server deployment using Nginx.
This knowledge directly supports my career aspirations in DevOps and Cloud Engineering, providing foundational skills for automating infrastructure and managing cloud-hosted applications.
References
DevOps Engineers
Cloud Engineers
Site Reliability Engineers
Author
Uyiosa Praise Oboite
LinkedIn Profile
Top comments (0)