In this guided project, you will deploy a secure Nextcloud instance on Azure Cloud, leveraging Azure's fundamental architecture and topology. You will learn how to:
- Create a resource group
- Set up a virtual network (Vnet) and subnet
- Protect the subnet with a network security group (NSG)
- Deploy Bastion for secure Virtual Machine (VM) connections
- Create an Ubuntu Server virtual machine (VM)
- Install Nextcloud via SSH using Bastion
- Publish an IP address
- Create a DNS label
- Azure subscription (sign up for a free trial at https://azure.com/free)
- Basic understanding of networking concepts (IP addresses, virtual networks, subnets)
- Log in to Azure Portal.
- Click "Create a resource" under "Azure services."
- Search for "Resource group" and click "Create."
- Name your resource group (e.g., RG-USE-Nextcloud).
- Choose the US East region.
- Click "Review + create" and then "Create."
Creating an Azure Resource Group
- Go to your resource group (RG-USE-Nextcloud).
- Click "Create" and search for "Virtual Network."
- Click "Create" and name your virtual network (e.g., VNET-USE-Nextcloud).
- Choose the East US region.
- Click "IP Addresses" at the top bar or click "Next" -> "Next" to get to the "IP Addresses" section.
- Leave the default address space (10.0.0.0/16).
- Edit the default subnet:
- Change the name from "default" to "SNET-USE-Nextcloud."
- Keep the address range (10.0.0.0/24).
- Click "Save."
- Click "Review + create" and then "Create."
Configuring Virtual Network and Subnet
- Go to your resource group (RG-USE-Nextcloud).
- Click "Create" and search for "Network security group."
- Click "Create" and name your Network Security Group (e.g., NSG-USE-Nextcloud).
- Click "Review + create," then "Create."
- Associate the NSG with your subnet:
- Go back to the resource group and click on your virtual network (VNET-USE-Nextcloud).
- From the left pane, expand "Settings" and click "Subnets."
- Click on the subnet name (SNET-USE-Nextcloud).
- Scroll down to "Security" and select the Network security group (NSG-USE-Nextcloud).
- Click "Save."
Note: To view your virtual network architecture, open the virtual network, expand "Monitoring" and click "Diagram" from the left pane.
- Go to the resource group (RG-USE-Nextcloud).
- Click on the virtual network (VNET-USE-Nextcloud), expand "Settings" and click "Subnets."
- Click the "Subnet" button and select "Azure Bastion" as the subnet purpose.
- Automatically generate the suggested name "AzureBastionSubnet."
- Click "Add."
- Create the Bastion resource:
- Go back to the resource group.
- Click "Create" and search for "Bastion."
- Click "Create" and name your Bastion (e.g., BASTION-USE-Nextcloud).
- Associate Bastion with your virtual network.
- Rename the "Public IP address name" to "BASTIONIP-USE-Nextcloud."
- Click "Review + create," then "Create."
Note: After checking your architecture, you will see that the Azure Bastion subnet has been added to your virtual network.
Bastion Host Deployment Configuration
Creating and Configuring Bastion Subnet
- Go to your resource group (RG-USE-Nextcloud).
- Click "Create" and search for "Ubuntu Server 20.04 LTS."
- Click "Create" and name your VM (e.g., VM-USE-Nextcloud).
- Choose a basic size (Standard_B1s).
- Select "SSH public key" for authentication and enter a username.
- Rename the "Key pair name" to "VM-USE-Nextcloud_SSHkey."
- Select "None" for public inbound ports.
- Click "Networking" and select "None" for the public IP option.
- Click "Review + create" and then "Create."
Important Note: When you click "Create," Azure will prompt you to generate a new key pair. Download it for later use.
Ubuntu Server VM Deployment Configuration
- Go to your resource group (RG-USE-Nextcloud).
- Click the virtual machine (VM-USE-Nextcloud).
- From the top menu, click "Connect," then choose "Connect via Bastion."
- For the "Authentication Type," choose "SSH Private Key from Local File."
- Enter the "Username" created earlier, then browse to select the SSH key downloaded previously.
- Click "Connect."
- Install Nextcloud with
sudo snap install nextcloud
. - Create an admin account with
sudo nextcloud.manual-install admin 1P@ss$0k
. - Enable HTTPS with
sudo nextcloud.enable-https self-signed
.
Note: For enabling HTTPS, we used self-signed for simplicity. Type exit
then the Enter
key to disconnect from the virtual machine.
Connecting to VM via Bastion Host
Installing and Configuring Nextcloud on VM
- Go to your resource group (RG-USE-Nextcloud).
- Click the virtual machine (VM-USE-Nextcloud).
- Expand "Networking" and click "Network settings."
- Click the "Network interface / IP configuration" (e.g., vm-use-nextcloud202_z1 / ipconfig1).
- Ensure "IP configurations" is selected; then click "ipconfig1."
- Under "Public IP address settings," select "Associate public IP address" and click "Create a public IP address."
- Name the public IP address "VMIP-USE-Nextcloud" and click "Ok."
- Click "Save."
- Go back to the virtual machine (VM-USE-Nextcloud) and click "Overview."
- Verify your assigned public IP address.
- Open your virtual machine (VM-USE-Nextcloud), then click "Networking" and "Network settings."
- Scroll up to the "Network security group" section and click "Create port rule" then "Inbound port rule."
- Select "IP addresses" as the "Source."
- For "Source IP addresses/CIDR ranges," paste your laptop/desktop's public IP address (obtained from https://whatsmyip.com).
- Select "IP addresses" for "Destination" and enter your virtual machine's private IP address (e.g., 10.0.0.4).
- Select "HTTPS" as the "Service."
- Leave "Action" as "Allow" and name the rule "AllowNextcloudHTTPSInbound."
- Click "Add."
- Ensure your laptop/desktop's public IP address is static or update the rule accordingly.
- Consider restricting access to specific IP addresses or CIDR ranges.
- Review Azure's security best practices for network security groups.
- Important: Prior to this step, accessing the public IP address in a browser would not work due to the lack of an inbound HTTPS rule in the network security group.
- After adding the rule, accessing the public IP address (e.g., https://52.168.107.188) will display a "Your connection is not secure" warning due to the self-signed certificate. Clicking "Advanced" and "Proceed" may still result in Nextcloud blocking access ("Access through untrusted domain").
- To resolve this, create a DNS entry for your public IP address and configure Nextcloud accordingly (covered in the next step).
Configuring Inbound Security Rule
- Go to your resource group (RG-USE-Nextcloud).
- Click on the virtual machine network interface controller (VMIP-USE-Nextcloud).
- From the left pane, Expand "Settings" and click "Configuration."
- Set a DNS name label (e.g., tetteisnextcloud) in the "DNS name label (optional)" box.
- Click "Save."
- Go back to the resource group and click on the virtual machine.
- From the left pane with "Overview" selected, view both the public IP and DNS name.
- Connect to the virtual machine following Step 6.
- Update Nextcloud's trusted domains with
sudo nextcloud.occ config:system:set trusted_domains 1 --value=tetteisnextcloud.eastus.cloudapp.azure.com
. - Exit the SSH connection by typing "exit."
- Enter your label in the browser (e.g., tetteisnextcloud.eastus.cloudapp.azure.com).
Verifying IP and DNS Configuration
Accessing Nextcloud Login Page
Congratulations! You've successfully deployed a secure Nextcloud instance on Azure Cloud. Remember to stop and delete your resources when not in use to avoid incurring costs.
- Use Azure's built-in security features to protect your resources.
- Regularly update and patch your Nextcloud installation.
- Monitor your resources' performance and adjust as needed.
Empty Resource Group (Pre-Deployment)
Resource Group with Deployed Resources