Skip to content
Jeremy Max

Setup Nextcloud with S3 compatible primary storage

Nextcloud, S31 min read

By default Nextcloud stores your files within the directory that holds the installation itself. This has obvious drawbacks as the size of your disk is limited. Fortunately you can easily create a Nextcloud installation that uses an S3 compatible storage back-end as its primary method of storage.

NOTE Please keep in mind this will only work for a completely new installation of Nextcloud, so if you already have a Nextcloud server up and running, you want to save all that data and then import it to your new installation.

Below you'll find the snippet that will have to be inserted into your config.php file.

1'objectstore' => array(
2 'class' => '\\OC\\Files\\ObjectStore\\S3',
3 'arguments' => array(
4 'bucket' => 'nextcloud-data',
5 'autocreate' => true,
6 'key' => 'my-key',
7 'secret' => 'my-secret',
8 'hostname' => 'https://{my-domain}',
9 'port' => 443,
10 'use_ssl' => true,
11 'region' => '',
12 'use_path_style'=>true
13 ),
14),

Whilst most of the values are pretty self explanatory, I want to go over some of them. On line 5 we are saying that if the bucket named "nextcloud-data" does not exist, Nextcloud should create it. On line 11 despite region being empty, it has to be included as otherwise Nextcloud will throw errors.

On line 12 we are specifying that the bucket name is not a subdomain of the url, but rather a path. So instead of having something like this [bucket_name].s3.amazonaws.com , you'd have something like this s3.amazonaws.com/[bucket_name]. If your provider has the bucket name as a subdomain, you can set use_path_style to false.

Once you've done all that, you should have a working installation of Nextcloud that uses an S3 compatible primary storage backend.