Nextcloud is a popular open-source file-sharing platform that can be self-hosted on your own server. Docker is a containerization technology that makes it easy to deploy and manage Nextcloud in a container. In this tutorial, we'll walk through the process of installing Nextcloud usint the Apache Docker image, opening the correct UFW ports, and configuring the trusted domains in the config.php file for use with a public IP.
Prerequisites
- A Debian or Ubuntu based distribution of Linux
- Docker installed
Install Nextcloud Using Docker
To install Nextcloud using the Apache Docker image, we'll use the official Nextcloud Docker image available on Docker Hub. (Note: You must be Root or Sudo to use Docker commands.) Here are the steps:docker pull nextcloud
docker run -d -p 8080:80 nextcloud
docker ps
You have now successfully installed Nextcloud using the Apache Docker image. Note your container ID number and name in the output as I will be referring to it as <container-ID> going forward. You will still need to open the following ports to be able to access NextCloud from other devices other than your host system or to access it from your host system using your public IP address.
Opening UFW Ports
To allow incoming traffic to your Nextcloud instance, we need to open the correct ports in UFW. Here are the steps:ufw allow 8080
$ ufw allow 80
$ ufw allow 443
2. Reload UFW:
ufw reload
Opening Bash in the Docker Container
docker exec -it <container-id> bash
Updating the Container
apt-get update && apt-get install nano
Editing the config.php File
cd /var/www/html/config/
$
nano config.php
Add the public IP address to the
trusted_domains
array:'trusted_domains' =>
array (
0 => 'localhost:8080',
1 => 'your_public_ip_address',
),
Note: Be sure to replace your_public_ip_address with your own public IP address. Save and exit the file.
Congratulations! You have now successfully configured Nextcloud to use
a public IP address. You can access your Nextcloud instance by navigating to http://your_public_ip_address in your web browser.