Setting up Nextcloud with S3-compatible primary storage
Nextcloud stores your files on the same disk as the installation by default. That works fine until your disk fills up. A better approach is to point Nextcloud at an S3-compatible storage backend from the start.
One important thing to note: this only works for brand new installations. If you already have a Nextcloud server running, you will need to back up your data first and import it into the new installation afterward.
The config
Add this block to your config.php file:
'objectstore' => array(
'class' => '\\OC\\Files\\ObjectStore\\S3',
'arguments' => array(
'bucket' => 'nextcloud-data',
'autocreate' => true,
'key' => 'my-key',
'secret' => 'my-secret',
'hostname' => 'https://{my-domain}',
'port' => 443,
'use_ssl' => true,
'region' => '',
'use_path_style' => true
),
),What these values mean
Most of it is self-explanatory, but a few things are worth calling out:
autocreate tells Nextcloud to create the bucket named "nextcloud-data" if it does not already exist. Handy for a fresh setup.
region needs to be included even if you leave it empty. Without it, Nextcloud throws errors. I spent more time debugging that than I'd like to admit.
use_path_style controls how the bucket name appears in the URL. When set to true, you get s3.amazonaws.com/[bucket_name] instead of [bucket_name].s3.amazonaws.com. If your provider uses the subdomain style, set this to false.
That's it
Once you have the config in place, Nextcloud will use your S3-compatible storage as the primary backend. All file uploads go straight to the bucket. It is a simple change that saves you from running into disk space issues down the road.
Sources
Related posts
Self-hosting with Coolify: a PaaS on your own server
How Coolify turns your VPS into a Heroku-like platform for deploying apps, databases, and services with a clean web UI.
Backup strategies for self-hosted data
The 3-2-1 backup rule applied to self-hosted services, with practical tools and patterns I use to protect my data.
Self-hosting a media server with Jellyfin
Setting up Jellyfin to stream movies, music, and photos across all my devices without a Plex subscription.
Enjoying the blog? Subscribe via RSS to get new posts in your reader.
Subscribe via RSS