Using Vultr Object (S3) Storage with Mastodon

Using Vultr Object (S3) Storage with Mastodon

This guide will show you how to utilise Vultr Object (S3) Storage with your Mastodon instance to save your local server resources.

Theoretically, non-Amazon S3-compatible storage should be just that: Compatible with anything designed for S3, however, when going through the Mastodon installer, there are 4 rather prescriptive options for Object/S3 storage.

After saying yes to "Do you want to store uploaded files on the cloud? (y/N)" you are presented with 4 options:

Amazon S3
Wasabi
Minio
Google Cloud Storage

However, I've recently been testing Vultr services and saw they had S3-compatible storage (shown as Objects in the Vultr account menu).

After creating an instance, and then a bucket, I went through various combinations in the Mastodon installer trying to set the bucket as the location for 'media_attachments', and got it to work using the Minio option.

For the endpoint URL, set the region storage URL, not including the bucket name. Then set only the bucket name, then enter the access and secret keys.

Do you want to store uploaded files on the cloud? yes
Provider Minio
Minio endpoint URL: https://ams1.vultrobjects.com
Minio bucket name: testbits01
Minio access key: XXXXXXXXXXXXXXXXXXXX
Minio secret key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Do you want to access the uploaded files from your own domain? no

After entering that, complete the installation, log in with your admin user and test a file upload.

If it doesn't work, you'll get a 500 error or the 503 error below:

Once you've seen that it uploads, you can go back to your Vultr bucket and see that the number of objects has increased!

It should be noted that there are various security and practicality concerns in moving the content to a bucket like this (for example, you should make sure that someone can't just browse to the root of an S3 bucket and browse content, which is fine in this case - see below). Still, once you've hit a certain threshold of users, you might find your server's local drive filling up and that it's not cost-effective to add more local storage, in which case, S3 is definitely the next step for you!

Browsing to the root URL doesn't allow browsing of the whole bucket.

That's it! If you followed along, you've set Mastodon to use an external Vultr Object Storage (S3) bucket for media attachments and validated that the objects are being uploaded correctly. I'll be adding more along these lines soon (including serving from the bucket from your own sub-domain and caching the files), so please leave a comment if there's anything you want covered, or let me know over at @techbitsio.



Great! Next, complete checkout for full access to techbits.io
Welcome back! You've successfully signed in
You've successfully subscribed to techbits.io
Success! Your account is fully activated, you now have access to all content
Success! Your billing info has been updated
Your billing was not updated