Like I mentioned in my previous post, Setting up your own Wireguard VPN for added online privacy, I said I’d show you how I set up my Nextcloud instance to keep joogle from spying on my data. I set up my Nextcloud on the same VPS that I used for my Wireguard VPN, and I did so with Docker, because it is quick and easy to set up.
This tutorial assumes you already have a domain & nextcloud subdomain set up in your server’s DNS records, and docker & docker-compose installed on your server. If you don’t you can learn how to install them here: Get Docker.
Installing Nextcloud on docker is super easy. You can be up and running with a fresh new instance in minutes.
First we want to create a network for our docker containers:
docker network create nextcloud_network
Next we want to create a docker-compose.yaml file, which will contain all the info for our docker containers. We’ll be creating the following docker containers on the same yaml file:
- Nginx reverse proxy (routes traffic to your nextcloud instance docker container)
- Let’s Encrypt (uses ssl certificate to use encryption to secure your nextcloud instance)
- MariaDB (Database to store your data for your nextcloud instance)
- Nextcloud (your actual nextcloud instance)
To accomplish all this, create a file with your favorite text editor called:
Add the following to the docker-compose.yaml file (be sure to add the unique information for user/password/domain/email for your particular instance):
version: '3' services: proxy: image: jwilder/nginx-proxy:alpine labels: - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true" container_name: nextcloud-proxy networks: - nextcloud_network ports: - 80:80 - 443:443 volumes: - ./proxy/conf.d:/etc/nginx/conf.d:rw - ./proxy/vhost.d:/etc/nginx/vhost.d:rw - ./proxy/html:/usr/share/nginx/html:rw - ./proxy/certs:/etc/nginx/certs:ro - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/tmp/docker.sock:ro restart: unless-stopped letsencrypt: image: jrcs/letsencrypt-nginx-proxy-companion container_name: nextcloud-letsencrypt depends_on: - proxy networks: - nextcloud_network volumes: - ./proxy/certs:/etc/nginx/certs:rw - ./proxy/vhost.d:/etc/nginx/vhost.d:rw - ./proxy/html:/usr/share/nginx/html:rw - /etc/localtime:/etc/localtime:ro - /var/run/docker.sock:/var/run/docker.sock:ro restart: unless-stopped db: image: mariadb container_name: nextcloud-mariadb networks: - nextcloud_network volumes: - db:/var/lib/mysql - /etc/localtime:/etc/localtime:ro environment: - MYSQL_ROOT_PASSWORD=YOURPASSWORDHERE - MYSQL_PASSWORD=YOURMYSQLPASSWORDHERE - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud restart: unless-stopped app: image: nextcloud:latest container_name: nextcloud-app networks: - nextcloud_network depends_on: - letsencrypt - proxy - db volumes: - nextcloud:/var/www/html - ./app/config:/var/www/html/config - ./app/custom_apps:/var/www/html/custom_apps - ./app/data:/var/www/html/data - ./app/themes:/var/www/html/themes - /etc/localtime:/etc/localtime:ro environment: - VIRTUAL_HOST=NEXTCLOUD(DOT)YOURDOMAINHERE - LETSENCRYPT_HOST=NEXTCLOUD(DOT)YOURDOMAINHERE - LETSENCRYPT_EMAIL=YOUREMAILADDRESSHERE restart: unless-stopped volumes: nextcloud: db: networks: nextcloud_network:
Next, you’ll need to start all your containers by issuing the following command:
docker-compose up -d
To doublecheck and make sure that it worked, type to list all your docker containers:
docker ps -a
You should see some output which looks like this:
Now, you can navigate to the nextcloud domain and finish the install setup. You’ll need to add your username, password, and database name you configured via the
MYSQL_DATABASE sections of the docker-compose.yaml file. You’ll also need to change
db and click Finish Setup.
Now your nextcloud instance is ready to use. You now have your own surveillance and censorship free alternative to google drive, calendar, contacts, notes and more. Enjoy!
If you’d like to support my work
You can donate here with Bitcoin, Lightning Network, or Monero
Or you can donate to my crowdfund with Bitcoin, Lightning Network, or Monero:
You can also become a monthly Librepatron, with Bitcoin, Lightning Network, or Monero: