Nextcloud
Nextcloud can be installed as a Snap, or as a Docker container. Here we'll show how to set it up as a Docker container using the default official image that uses Apache, paired with MariaDB.
This stack is intended to be used behind Caddy V2 as reverse proxy.
Docker Compose
This is a working compose stack:
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
app:
image: nextcloud:26.0.1
restart: always
ports:
- 7269:80
links:
- db
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_HOST=${MYSQL_HOST}
- APACHE_DISABLE_REWRITE_IP=${APACHE_DISABLE_REWRITE_IP}
- TRUSTED_PROXIES=${TRUSTED_PROXIES}
- OVERWRITEHOST=${OVERWRITEHOST}
- OVERWRITEPROTOCOL=${OVERWRITEPROTOCOL}
- OVERWRITECLIURL=${OVERWRITECLIURL}
.env
Be sure to set the .env appropriately:
MYSQL_ROOT_PASSWORD=saiJZq3xb8LX5CoEkCis
MYSQL_PASSWORD=4WDsD99gLeQuq5Vvj4tf
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_HOST=db
APACHE_DISABLE_REWRITE_IP=1
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
OVERWRITEHOST=cloud.gomarcd.dev
OVERWRITEPROTOCOL=https
OVERWRITECLIURL=https://cloud.gomarcd.dev
Add the TRUSTED_PROXIES values under Administration Settings > Office > Allow list for WOPI requests.
Caddy
Add header Strict-Transport-Security max-age=31536000; to the Caddyfile:
cloud.gomarcd.dev {
header Strict-Transport-Security max-age=31536000;
reverse_proxy 127.0.0.1:7269
}
Backups
Volumes are stored in /var/lib/docker/volumes/nextcloud_db and /var/lib/docker/volumes/nextcloud_nextcloud.