I have a compute instance that is running Owncloud, which I use to backup my files and whatnot.
While I was configuring the instance and uploading my files, I quickly realized that my instance’s storage is very limited and did not have enough space to actually house all of my potential future backups.
But then I had an idea: what if I could hook up Cloudflare’s R2 service to Owncloud?
Stick with me as I show you how to do exactly that in this article.
Table of contents#
- Creating a bucket
- Installing the S3 extension for Owncloud
- Setting up R2 for your Owncloud instance
💡 This guide assumes you’re running an instance of Owncloud on a Docker container using
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 a bucket#
Go to your Cloudflare dashboard and navigate to the R2 page. Then click on the Create bucket button.
💡 When creating 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
Once you’re done with that, head back to the R2 page, click on the Manage R2 API Tokens link and 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.
- Permissions: Make sure you set this to Edit! Otherwise you may run into permission issues when uploading files.
- TTL: If you just want to create this token and forget about it, set this to Infinity. Otherwise, this option is up to you.
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#
You’ll want to replace the following options:
- bucket: This is your unique R2 bucket name that you created earlier.
owncloud-instancefor 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!
/owncloud-instancebit from the URL can be removed)
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! ❤️