When tech giants monitor our files, scan our documents, and monetize our data, it's time to consider alternatives that respect our privacy. Enter Nextcloud—a powerful, open-source platform that gives you complete control over your data. It's like having your own private Google Drive, Dropbox, and Google Docs, but without corporations spying on you.

Unlike Google Drive or OneDrive, where your files are stored on servers you don't control and can be used to train AI, Nextcloud keeps your data exactly where you want it: on your own computer, in your own home. You maintain full ownership, there's no data mining, and you're not the product being sold.

Today, I'll show you how to set up Nextcloud using Docker on Linux and (optionally) securely expose it to the internet using Cloudflare Tunnels—no router port forwarding required!


Requirements

  • An old computer or server running Linux (I'm using Ubuntu 22.04 LTS)
  • (Optionally) A domain managed by Cloudflare

Note: If you are not using Ubuntu or another Debian-based Linux distribution, you will need to research the equivalent commands for your OS


Step 1: Update Your System

First, ensure your system is up-to-date:

sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

We'll use Docker to simplify the Nextcloud setup.

curl -fsSL get.docker.com | sudo sh

Step 3: Set Up Nextcloud

Nextcloud's "All-in-One" (AIO) Docker image makes deployment straightforward. Run the following command to start the master container:

sudo docker run \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 8080:8080 \
--env APACHE_PORT=11000 \
--env APACHE_IP_BINDING=0.0.0.0 \
--env APACHE_ADDITIONAL_NETWORK="" \
--env SKIP_DOMAIN_VALIDATION=true \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
ghcr.io/nextcloud-releases/all-in-one:latest

This command:

  • Starts the Nextcloud AIO container
  • Exposes the AIO interface on port 8080
  • Configures Apache (Nextcloud's web server) to use port 11000

Step 4: Create a Cloudflare Tunnel

If you do not have a Cloudflare-managed domain, skip to Step 7. Otherwise, continue to set up Cloudflare so you can access Nextcloud using your domain.

  1. Go to the Cloudflare Zero Trust Dashboard.
  2. Navigate to Networks > Tunnels and click Create a Tunnel.
  3. Name your tunnel (e.g., nextcloud-tunnel) and select Cloudflared as the connector type.
  4. Copy the Docker command provided by Cloudflare and run it in your terminal.

Step 5: Connect Docker Containers to the Same Network

To allow the Cloudflare Tunnel to communicate with Nextcloud, both containers must be on the same Docker network.

  1. Create a new Docker network:
sudo docker network create nextcloud
  1. Connect the Nextcloud container to the network:
sudo docker network connect nextcloud nextcloud-aio-mastercontainer
  1. Find the name of your Cloudflared container:
sudo docker ps
  1. Connect the Cloudflared container to the network:
sudo docker network connect nextcloud <cloudflared-container-name>

Step 6: Configure the Tunnel in Cloudflare

We will now finish setting up the tunnel.

  1. Go back to the Cloudflare Tunnel page. Your connector should now show a "Connected" status.
  2. Click Next and configure your public-facing domain/subdomain.
    1. Subdomain: e.g., nextcloud.yourdomain.com
    2. Service: Select HTTP
    3. URL: Enter your server's local IP and port 11000 (e.g., 192.168.0.128:11000)

Step 7: Finalize Nextcloud Setup

Now that we're done with Cloudflare, we can finish the Nextcloud setup process.

  1. Open your browser and go to your server's IP on port 8080 (e.g., 192.168.0.128:8080).
  2. Follow the AIO setup wizard to configure Nextcloud.
  3. Once complete, visit your domain (e.g., nextcloud.yourdomain.com) - you should see the Nextcloud login page!

Important Notes

  • The AIO setup will provide an initial username and password - save these for your first login!
  • After logging in, create a new admin account and disable the temporary credentials.
  • Nextcloud offers not just file storage, but also calendar, contacts, document collaboration, and more - all under your control!

Troubleshooting Tips

  • If the tunnel fails to connect, verify both containers are on the same Docker network
  • Ensure your domain's DNS in Cloudflare is set to "Proxied" (orange cloud)
  • Check the Cloudflared container logs:
sudo docker logs <cloudflared-container-name>

Taking control of your data has never been more important—or more accessible. With Nextcloud and Cloudflare Tunnels, you get an enterprise-grade setup that respects your privacy and puts you back in the driver's seat.