This repository contains the necessary instructions for setting up a secure network within Azure, including installing and configuring Nginx on an Ubuntu VM within the Azure Virtual Network (VNet). Below are the steps to install and configure Nginx on an Ubuntu VM hosted on Azure.
To access the VM securely, use Azure Bastion. Follow these steps to connect to your VM:
- Go to the Azure portal.
- Navigate to Bastion under your created VNet (e.g.,
vnet-demo-network-Bastion
). - Click Connect.
- Choose SSH as the authentication type.
- Use your SSH private key (e.g.,
.pem
file) to authenticate. - Enter the username (
azureuser
) and select the private key you downloaded when you created the VM. - Click Connect. This will open a terminal session on the VM.
Once connected to your VM, it's important to update the package list and upgrade existing packages:
sudo su -
sudo apt update
sudo apt upgrade -y
Now, install Nginx on the Ubuntu VM:
sudo apt install nginx -y
After installation, start the Nginx service and enable it to start on boot:
sudo systemctl start nginx
sudo systemctl enable nginx
Create a simple static HTML page that will be served by Nginx. You can edit the default HTML file or create a new one:
sudo vim /var/www/html/index.html
Add your HTML content to this file. You can find the HTML code used in this project in the repository. If you'd like to see the exact HTML content I used, you can access it directly in the index.html file of this repository Save and exit the editor by pressing Esc then typing :wq and pressing Enter.
To ensure Nginx picks up the changes to the HTML file, restart the Nginx service:
sudo systemctl restart nginx
To verify that Nginx is serving the page correctly, run the following command from the Bastion terminal:
curl localhost:80