How to setup Nextcloud AIO (with Docker & Caddy)
Untested
Description
Nextcloud is an open-source cloud storage platform.
It's a FOSS alternative to Google Drive, Microsoft OneDrive, Dropbox (and others).
Create a DNS record
Go to cPanel and add a new record (e.g. nextcloud.akdscloud.eu).
Caddy
nextcloud.akdscloud.eu:443 {
# TLS and security headers
header {
Strict-Transport-Security "max-age=31536000;"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
Referrer-Policy "no-referrer-when-downgrade"
}
request_body {
max_size 34359738368 # 32GB in bytes
}
# Enhanced reverse proxy configuration
reverse_proxy localhost:11000 {
header_up X-Real-IP {remote_host}
header_up Host {host}
}
}
Folders
Create the folder structure
# Create Nextcloud data mount point
sudo mkdir -p /media/ncdrive
sudo chown dan:dan /media/ncdrive
sudo chmod 750 /media/ncdrive
Mount Storage for Nextcloud
# Get drive UUID
sudo blkid
# Add to /etc/fstab (replace UUID with your actual drive UUID)
sudo nano /etc/fstab
# Add line:
UUID=your-drive-uuid /media/ncdrive btrfs defaults 0 0
# Mount the drive
sudo mount -a
# Create and set permissions for Nextcloud data directory
sudo mkdir -p /media/ncdrive/ncdata
sudo chown -R 33:33 /media/ncdrive/ncdata
sudo chmod -R 750 /media/ncdrive/ncdata
# Verify permissions
ls -la /media/ncdrive
ls -la /media/ncdrive/ncdata
Docker
-
Add the
nextcloudsection to yourdocker-compose.ymlfile:services: nextcloud-aio-mastercontainer: image: nextcloud/all-in-one:latest container_name: nextcloud-aio-mastercontainer restart: unless-stopped ports: - "8080:8080" - "8443:8443" environment: - NEXTCLOUD_DATADIR=/media/ncdrive/ncdata - NEXTCLOUD_MOUNT=/media/ncdrive - APACHE_PORT=11000 - APACHE_IP_BINDING=127.0.0.1 - NEXTCLOUD_DOMAIN=nextcloud.akdscloud.eu - NEXTCLOUD_UPLOAD_LIMIT=32G - NEXTCLOUD_MEMORY_LIMIT=2048M - PHP_MEMORY_LIMIT=2048M - PHP_UPLOAD_LIMIT=32G - REDIS_MEM_LIMIT=1024M - PHP_MAX_EXECUTION_TIME=3600 - MYSQL_INNODB_BUFFER_POOL_SIZE=4G - COLLABORA_DICTIONARIES=en_US - NC_ENABLE_PREVIEWS=true - PREVIEW_CONCURRENCY_DOWN=4 - PREVIEW_CONCURRENCY_UP=2 - PHP_PM_MAX_CHILDREN=32 - PHP_PM_START_SERVERS=4 - PHP_PM_MIN_SPARE_SERVERS=4 - PHP_PM_MAX_SPARE_SERVERS=16 - PHP_OPCACHE_MEMORY_CONSUMPTION=256 - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=64 - REDIS_MAX_MEMORY_POLICY=volatile-lru - MYSQL_TRANSACTION_ISOLATION=READ-COMMITTED - NC_DEFAULT_PHONE_REGION=RO volumes: - nextcloud_aio_mastercontainer:/mnt/docker-aio-config - /var/run/docker.sock:/var/run/docker.sock:ro - /media/ncdrive:/media/ncdrive depends_on: - caddy volumes: nextcloud_aio_mastercontainer: name: nextcloud_aio_mastercontainer # This line is not allowed to be changed -
Download and start
nextcloud: -
Restart Caddy to get an SSL certificate (details here)
Try it out
See if you can access the nextcloud web interface.
Troubleshooting
If it doesn't work, see the troubleshooting guide.
Configuration
Initial Setup
- Access the Nextcloud AIO interface at
http://your_server_ip:8080 - Complete the initial setup process
- When prompted, configure:
- Domain:
nextcloud.akdscloud.eu - Data directory:
/media/ncdrive/ncdata
- Domain:
How to change Nextcloud environment variables
Add/modify the (new) variable to your docker-compose file (in nextcloud --> environment).
Then simply restart the services:
Also, you will need to stop the NC containers (from the web interface) and then restart them.
Afterwards, check if your changes we made.
No data is lost during this process. And you don't need to redo the whole setup again.
Links
https://nextcloud.com/all-in-one/
https://github.com/nextcloud/all-in-one
https://github.com/nextcloud/all-in-one/blob/main/compose.yaml
https://github.com/nextcloud/all-in-one/discussions/575
https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html
https://github.com/nextcloud/all-in-one?tab=readme-ov-file#how-to-change-the-default-location-of-nextclouds-datadir
https://github.com/nextcloud/all-in-one/blob/main/compose.yaml
https://github.com/nextcloud/docker#auto-configuration-via-environment-variables
https://help.nextcloud.com/t/trying-to-get-aio-up-again-after-deleting-mastercontainer/186413
https://github.com/nextcloud/all-in-one/discussions/1422