There are a ton of cloud storage providers out there including the large players: Dropbox, OneDrive, Apple Cloud and so on. Though some of these have pretty good security, the files in those storages are still accessible to the admins of said services – and in extension to governments and other third party actors.
Do I have anything to hide? No. Do I want the government or random hackers and script kiddies looking at my personal picture archives? No again. So a self-hosted solution is the way to go.
Enter Nextcloud, an ownCloud fork. I decided to run the Docker version behind an NGINX proxy server.
It’s pretty simple this time, let’s jump into it!
Step 1 – Install Docker and docker-compose
We will use sudo
, apt
and apt-get
for this. All these tools usually come with Ubuntu, so no need to install them. Let’s grab us some nice Docker stuff.
In addition, you might need to add the server user for the website to the Docker group (and create a docker group, if not in place already):
That’s all the installation stuff server-wise. Next, let’s set up NGINX.
Step 2 – Set up NGINX
Let’s create a configuration file for the webpage (or add a new server to an existing configuration file).
At this point you’d typically make sure to add a certificate, e. g. utilising certbot --nginx
to do so. I won’t cover that here.
Step 3 – Add docker-compose.yml and db.env
Let’s start with the docker-compose.yml
file. You can copy it from here, just make sure to use a free port. 30xx should be fine. Use netstat -tunlep | grep LISTEN | awk '{print $4}'
to make sure.
version: '3'
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- ./db:/var/lib/mysql
env_file:
- db.env
redis:
image: redis
restart: always
app:
image: nextcloud:latest
build: ./app
restart: always
ports:
- 127.0.0.1:3000:80
# remember the port (3000) in the nginx file?
# Make sure this one is the same. And it's not in use, of course.
volumes:
- ./nextcloud:/var/www/html
environment:
- MYSQL_HOST=db
env_file:
- db.env
depends_on:
- db
- redis
cron:
build: ./app
restart: always
volumes:
- ./nextcloud:/var/www/html
entrypoint: /cron.sh
depends_on:
- db
- redis
volumes:
db:
nextcloud:
Save and add another file, this time db.env
:
Step 4 – Add the Dockerfile and the redis configuration file
Create a folder named app
in your site directory, and add two files to it.
Add some content to those files.
Step 5 – Cross your fingers and …
… run docker-compose
.
Check the output for errors. If you don’t see any, terminate the containers with Ctrl-C (once!).
Step 6 – Fire up a detached container
Run docker-compose again, so it starts some detached containers. Head to your website, and you should be able to follow the frontend installation process.
If everything went well, you should have a running Nextcloud instance. If not, let me know and I might add more to this tutorial.