Self-Host Nextcloud on Ubuntu (2026): Private Cloud Step-by-Step

Next Cloud Alternative For Google Drive Blog

Introduction

Looking for a private, secure, and self-hosted cloud storage alternative to Dropbox or Google Drive? Meet Nextcloud — a powerful open-source platform that lets you take full control of your files, calendars, contacts, and more. 🚀

In this guide, we’ll walk through how to install Nextcloud on Ubuntu Server using Docker and Caddy for HTTPS. This setup ensures maximum privacy, automatic SSL certificates, and a fully customizable cloud you control.

Why Host Nextcloud Yourself?

  • Full control over your data and privacy

  • No subscription fees — completely free

  • Access from anywhere via web, desktop, or mobile app

  • Scalable & flexible with plugins and integrations

For this setup, reliable hardware improves performance and stability.

Step 1: Prepare Your Ubuntu Server

First, create and access your Ubuntu server via SSH. Update your system to the latest packages:


sudo apt-get update
sudo apt-get upgrade -y

Step 2: Secure Your Server with a Firewall

Lock down unnecessary ports and only allow essential services like SSH, HTTP, and HTTPS:


sudo apt install ufw -y
sudo ufw allow 22 # SSH
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
sudo ufw enable
sudo ufw status verbose

Step 3: Install Docker on Ubuntu

Docker makes it easy to run Nextcloud in an isolated environment. Install it with:


sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add Docker’s repository:


echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

Install Docker and Compose Plugin:


sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
sudo docker run hello-world

Step 4: Install and Configure Caddy for HTTPS

Caddy automatically handles SSL certificates for your domain.


sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy -y

Edit the Caddyfile:

sudo nano /etc/caddy/Caddyfile

Example configuration with your domain:


yourdomain.com {
reverse_proxy localhost:8000
}

Without a domain (HTTP only):


:80 {
reverse_proxy localhost:8000
}

Restart Caddy:

sudo systemctl restart caddy

Step 5: Deploy Nextcloud with Docker Compose

Create a deployment folder and docker-compose.yml file:


mkdir ~/nextcloud
cd ~/nextcloud

Add the following content:


services:
nextcloud:
depends_on:
- postgres
image: nextcloud:apache
environment:
- POSTGRES_HOST=postgres
- POSTGRES_PASSWORD=nextcloud
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
ports:
- 8000:80
restart: always
volumes:
- nc_data:/var/www/html

postgres:
image: postgres:alpine
environment:
- POSTGRES_PASSWORD=nextcloud
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
restart: always
volumes:
- db_data:/var/lib/postgresql/data
expose:
- 5432

volumes:
db_data:
nc_data:

Start the containers:


sudo docker compose up -d

Step 6: Access Your Nextcloud Instance

Once the containers are running, open your browser and go to:

  • With domain: https://yourdomain.com

  • With IP address: http://your_server_ip

Complete the setup by creating an admin account with a strong password. Choose additional apps and plugins to enhance your cloud.

Final Thoughts

🎉 Congratulations! You’ve just set up your own self-hosted cloud storage with Nextcloud on Ubuntu using Docker and Caddy.

From here, you can:

  • Sync files with the Nextcloud desktop app or mobile app

  • Enable two-factor authentication for extra security

  • Add integrations like OnlyOffice or Collabora for online document editing

Now, your data stays 100% in your hands — no big tech involved.

Recommended Hardware

Running a private cloud is more reliable with dedicated storage.

🧪 New to cybersecurity?

Start here: Beginner Home Cybersecurity Lab Setup (2026)

Beginner Home Cybersecurity Lab Setup (2026 Guide) – Build a Safe Practice Environment

This article may contain affiliate links. If you purchase through them, I may earn a small commission at no extra cost to you.

 

Leave a Comment

Your email address will not be published. Required fields are marked *