Deployment guide

Nextcloud

Overview

Nextcloud is a popular open-source content-collaboration platform. It provides file sync and share, calendar, contacts, collaborative documents and a rich app ecosystem, all self-hosted inside your own Azure VNet for data residency and compliance.

The SecureAnyCloud image installs Nextcloud 30.0.14 (AGPL-3.0), served by nginx and PHP 8.3-FPM. It is backed by a local PostgreSQL 16 database and by Redis for file locking and caching. The Nextcloud data directory and the PostgreSQL datadir both live on a dedicated 60 GiB Azure data disk. The image generates a unique admin password and database password on the first boot of every VM, and SecureAnyCloud backs it with 24/7 support.

What you get:

  • Nextcloud 30.0.14 (web root /var/www/nextcloud), served by nginx on :80
  • PHP 8.3-FPM with every extension that Nextcloud requires (gd, curl, mbstring, intl, bcmath, gmp, imagick, apcu, pdo_pgsql, zip, exif, bz2)
  • A local PostgreSQL 16 database and Redis for the distributed and file-locking cache
  • A dedicated Azure data disk at /var/lib/nextcloud, which holds both the Nextcloud data/ directory and the PostgreSQL datadir
  • A per-VM admin account and database password, generated on first boot and recorded in a root-only file
  • nginx.service, php8.3-fpm.service, postgresql.service and redis-server.service as enabled systemd units, plus a 5-minute background-jobs timer
  • 24/7 SecureAnyCloud support

Prerequisites

You need an active Azure subscription, an SSH key pair, and a VNet with a subnet in the target region.

Standard_B4ms (4 vCPU / 16 GiB RAM) is a good starting point. Configure the NSG to allow inbound 22/tcp from your management network and 80/tcp for the web interface.

Nextcloud serves plain HTTP on port 80. For production, terminate TLS in front of it with your own domain and a certificate (for example with certbot).

Step 1 - Deploy from the Azure Marketplace

Sign in to the Azure Portal, choose Create a resource, search the Marketplace for Nextcloud by SecureAnyCloud, and select Create.

On the Basics tab, pick your subscription, resource group, region and size. Under Administrator account, choose SSH public key and paste your key. Under Inbound port rules, allow SSH (22) and HTTP (80).

Review the dedicated 60 GiB data disk on the Disks tab. Then select Review + create, followed by Create.

Step 2 - Deploy from the Azure CLI

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:nextcloud-ubuntu-24-04:default:latest
az vm create \
  --resource-group <your-rg> \
  --name nextcloud \
  --image sac1647283583153:nextcloud-ubuntu-24-04:default:latest \
  --size Standard_B4ms \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_ed25519.pub \
  --vnet-name <your-vnet> --subnet <your-subnet> \
  --public-ip-sku Standard
az vm open-port --resource-group <your-rg> --name nextcloud --port 80 --priority 1010

Step 3 - Connect to your VM

ssh azureuser@<vm-public-ip>

Step 4 - Confirm the services are running

The web tier, PHP runtime, database and cache all run as systemd units:

systemctl is-active nginx.service php8.3-fpm.service postgresql.service redis-server.service

Each line reports active. On first boot, the VM rotates the Nextcloud admin password and the database password to values unique to your instance.

Step 5 - Confirm the health endpoint

nginx serves an unauthenticated health probe, separate from the Nextcloud web root, which redirects to the sign-in page:

curl -s http://localhost/health

It returns ok.

Step 6 - Confirm Nextcloud is installed and healthy

Nextcloud's status.php endpoint reports the install state and version without requiring a login:

curl -s http://localhost/status.php

The JSON response contains "installed":true and "version":"30.0.14...".

Step 7 - Retrieve your admin password

The first boot of your VM generates a unique admin password and database password and writes them to a root-only file:

sudo cat /root/nextcloud-credentials.txt

This file contains NEXTCLOUD_ADMIN_USER (admin), NEXTCLOUD_ADMIN_PASSWORD, and the database name, user and password. Store the admin password somewhere safe.

Trust your VM's public address

First boot adds the address that Azure reports to Nextcloud's trusted domains. With a Standard SKU public IP (the Azure default, and the --public-ip-sku Standard in Step 2), the current image finds only the VM's private address (10.0.0.x). A browser at the public IP then shows Nextcloud's Access through untrusted domain page instead of the sign-in page. Check the list:

sudo -u www-data php /var/www/nextcloud/occ config:system:get trusted_domains

If the list holds only localhost, 127.0.0.1 and a 10. address, add the public IP on the VM. Azure's instance metadata service reports the public IP to the VM itself, and nothing leaves the VM:

PUBLIC_IP=$(curl -s -H Metadata:true 'http://169.254.169.254/metadata/loadbalancer?api-version=2020-10-01' | grep -o '"frontendIpAddress":"[^"]*"' | head -1 | cut -d'"' -f4)
PRIV=$(hostname -I | awk '{print $1}'); echo "public $PUBLIC_IP, private $PRIV"
sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 4 --value "$PUBLIC_IP"
sudo -u www-data php /var/www/nextcloud/occ config:system:set overwrite.cli.url --value "http://$PUBLIC_IP/"
sudo sed -i "s/\b$PRIV\b/$PUBLIC_IP/g; s/<ip>/$PUBLIC_IP/g" /root/nextcloud-credentials.txt

The change applies at once and survives reboots. The private address stays trusted too. Add a DNS name with the trusted_domains 3 command below.

Step 8 - Sign in to the web interface

Browse to http://<vm-public-ip>/ and sign in as admin with the password from Step 7. On first boot, the image adds the VM's detected public and private IPv4 addresses to Nextcloud's trusted domains, so you can reach it immediately on the VM's public IP.

If you front the instance with your own DNS name and see an "access through untrusted domain" page, add the name to the allowlist once with:

sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 3 --value your.domain.com

This host-header allowlist is a deliberate security control, and the image does not use a wildcard.

After you sign in, you land in the Files app, where you upload, organise and share files and folders. The left rail gives quick access to Recent, Favorites, Shares and Tags.

The Administration settings give you a system overview, security and setup warnings, background-jobs mode, logging and more.

The Apps area is where you enable, disable and update Nextcloud apps, including calendar, contacts, collaborative editing, and hundreds more from the app store.

Step 9 - Confirm the version from the command line

The occ command-line tool manages Nextcloud from the shell. Confirm the running version:

sudo -u www-data php /var/www/nextcloud/occ status

It prints installed: true and versionstring: 30.0.14.

Step 10 - Verify authentication over the API

Nextcloud's OCS user endpoint rejects unauthenticated requests and accepts your per-VM admin password. An unauthenticated request returns HTTP 401:

curl -s -o /dev/null -w '%{http_code}\n' -H 'OCS-APIRequest: true' http://localhost/ocs/v2.php/cloud/user

To prove end-to-end authentication, read your admin password from /root/nextcloud-credentials.txt (Step 7) and run this command from a shell: curl -u admin:<password> -H 'OCS-APIRequest: true' http://<vm-public-ip>/ocs/v2.php/cloud/user. It returns HTTP 200 with your user record as XML. A wrong password returns 401.

Step 11 - Confirm where your data and database live

Both the Nextcloud data directory and the PostgreSQL datadir sit on the dedicated Azure data disk. You can grow or snapshot them independently of the OS disk:

df -h /var/lib/nextcloud | tail -1

The mount /var/lib/nextcloud holds data/ (user files) and pgsql/main (the PostgreSQL cluster).

Step 12 - Maintenance

  • Admin CLI: run any management command with sudo -u www-data php /var/www/nextcloud/occ <command> (for example occ user:list or occ app:list).
  • Background jobs: a systemd timer runs cron.php every 5 minutes, which is Nextcloud's recommended mode. No action is needed.
  • TLS: put a reverse proxy or certbot in front of port 80 with your own domain before you expose the instance to the internet.
  • Backups: back up /var/lib/nextcloud/data, the PostgreSQL database, and /var/www/nextcloud/config/config.php.
  • Updates: unattended-upgrades applies OS security updates automatically. Upgrade Nextcloud itself with its built-in updater or occ.

Support

SecureAnyCloud maintains this image and provides 24/7 support. Contact sales@secureanycloud.com for assistance.

Deploy on Azure

Launch Nextcloud on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure