I have a compute instance that is running Owncloud, which I use to backup my files and whatnot. The problem is, my instance has very little storage to actually host anything.
Then I had an idea… what if I could hook up Cloudflare’s R2 service to Owncloud?
Table of contents#
- Preamble
- Creating an R2 bucket
- Installing the S3 extension for Owncloud
- Setting up R2 for your Owncloud instance
Preamble#
This guide assumes you’re running an instance of Owncloud on a Docker container using docker-compose.
If you don’t have an instance of Owncloud running on Docker, follow these steps:
You’ll need to install Docker first. The official Docker Docs page provides a guide on how to install Docker on just about every system.
Then, head over to Owncloud’s documentation page and install Owncloud on a Docker container.
Creating an R2 bucket#
Go to your Cloudflare dashboard and navigate to the R2 page.

You’ll want to create a bucket. Make sure you give this bucket a unique name, because you won’t be able to change it afterwards!
For the purposes of this guide, I’ll stick with the bucket name owncloud-instance
.

Once you’re done with that, head back to the R2 page, and click on the Manage R2 API Tokens link.
At the time of writing this guide, the link should be in the upper right corner.

Then, click on the Create API token button.
Bucket creation options#
Let’s go through each of the options on the page:
Token name: This is not that important, but if you want to be able to easily identify the R2 token on this page in the future, you can set a unique name here.
The name option for your R2 API token. Permissions: Make sure you set this to Edit! Otherwise you may run into permission issues when uploading files.
The permissions option for your R2 API token. TTL: If you just want to create this token and forget about it, set this to Infinity. Otherwise, this option is up to you.
The TTL option for your R2 API token.
When you’re done, click on the Create API Token button.
You’ll be able to see your Access Key ID and Secret Access Key values here. Keep them somewhere safe, as you will not be able to see them again!

Installing the S3 extension for Owncloud#
Once you’re done creating an R2 bucket, head over to your Owncloud admin dashboard.
Click on the menu bar located in the upper left corner, and select the Market tab.

Scroll down until you find the S3 Primary Object Storage extension, and install it.

Note: You’ll want this extension, and not the extension called External Storage: S3!
Setting up R2 for your Owncloud instance#
Before proceeding any further, make sure you back up all your data. Proceeding with the steps below will wipe any data you had on your Owncloud instance.
You’re done with all that? Great. It’s time to configure R2 to work on your Owncloud instance.
Run the following command to access the filesystem of your Owncloud Docker instance:
> docker exec -t -i owncloud_server /bin/bash
Head over to the config folder. The config folder should have the following files:
> ls
config.php objectstore.config.php overwrite.config.php
We’re looking to edit the config.php file. Add the following to the configuration file:
'objectstore' => [
'class' => '\\OC\\Files\\ObjectStore\\S3',
'arguments' => [
'bucket' => 'BUCKET',
'autocreate' => true,
'key' => 'ACCESS_KEY_ID',
'secret' => 'SECRET_ACCESS_KEY',
'hostname' => 'ACCOUNT_ID.r2.cloudflarestorage.com',
'port' => 443,
'use_ssl' => true,
'region' => 'auto',
],
]
S3 configuration options#
Replace the following:
- bucket: This is your unique R2 bucket name that you created earlier.
(I usedowncloud-instance
for this guide) - key: This is the Access Key ID that you obtained when creating the R2 bucket.
- secret: This is the Secret Access Key that you obtained when creating the R2 bucket.
- hostname: You can find the bucket hostname on the bucket page itself. Make sure to only include the URL name!
(the/owncloud-instance
bit from the URL can be removed)

Then, run docker restart owncloud_server
to apply the changes.
And that’s it! Log back in to your Owncloud admin dashboard, and your instance should utilize your Cloudflare R2 bucket as its primary storage.
Overall, it’s pretty painless for your Owncloud instance to utilize Cloudflare’s R2 service.
I will warn you though, Cloudflare’s base plan for R2 only includes 10 GB of storage per month.

But it all depends if you’re fine with that. :)
Hey! If you’re still here…
This is the first time I’m writing a blog post of this sort. Let me know if I did well, or if there’s anything I can improve with future blog posts. Thank you! ❤️
Comments Discuss this article with others here!