Category Archives: Spaces

Bluesky PDS DigitalOcean Spaces CDN Configuration

A CDN is a game changer for the Bluesky PDS

The TurtleIsland.social Mastodon and the TurtleIs.land Bluesky PDS have CDNs. It makes a huge difference for performance and economical storage capacity.

According to DigitalOcean: Spaces Object Storage is an S3-compatible object storage service that lets you store and serve large amounts of data. Each Space is a bucket for you to store and serve files. The built-in Spaces CDN minimizes page load times and improves performance.

For pricing details view here: DigitalOcean Spaces Pricing.

The following instructions assume your Bluesky PDS is already installed and running in a DigitalOcean Ubuntu 22.04 LTS droplet.

The following instructions also assume your domain’s DNS is controlled by DigitalOcean, and you have already subscribed to ‘Spaces Object Storage’.

Creating a Spaces Bucket

Click the ‘Create’ button at the top right of your DigitalOcean console, and select ‘Spaces Object Storage’.

This action leads to ‘Create a Spaces Bucket’ shown in the image above.

  • Choose a datacenter region – Preferably the same one your Bluesky PDS is hosted on
  • Content Delivery Network (CDN) – Checkmark ‘Enable CDN’
  • Choose a unique Spaces Bucket name – In this example I chose yehuda1491-sky
  • Select a project – Preferably the same one your Bluesky PDS is hosted on
  • Click the ‘Create a Spaces Bucket’ button at the bottom

Settings Tab

  • In the next screen, choose the Settings tab
  • File Listing – Leave ‘Restricted’
  • CDN (Content Delivery Network) – Choose ‘Change’, then ‘Edit CDN Settings’
  • Be sure ‘Enable CDN’ is still check marked and click ‘Add a new subdomain certificate’

Add a Custom Subdomain

  • On the ‘Use Let’s Encrypt’ tab, Select a domain and choose your domain. In this example I chose yehuda1491.com
  • Select a subdomain – Create a new subdomain, I added ‘spaces’
  • Certificate name – I added the subdomain ‘spaces.yehuda1491.com’
  • Then click the ‘Generate Certificate and Use Subdomain’ button

When that is done, click the ‘Save’ button.

CORS Configurations

CORS Configurations – Choose ‘Add’.

Set the following in the Advanced CORS Options dialog:

  • Origin – ‘*’
  • Allowed Methods – Checkmark ‘GET’
  • Allowed Headers – Click ‘Add Header, add ‘*’
  • Access Control Max Age – ‘3000’

Then click the ‘Save CORS Configuration’ button.

You can now upload a file from the Files tab. Be sure to set file permissions to ‘public’ and test your CDN. My test file is:
https://spaces.yehuda1491.com/cdn-test-file.jpg

Spaces Access Keys

Back on the settings tab, at the bottom. You need access keys. To generate Spaces access keys:

  • Access Keys – Choose ‘Create Access Key’.
  • Select access scope – Choose Limited Access.
  • Select the buckets and permissions – Checkmark yehuda1491-sky with Read/Write/Delete permissions.
  • Give this access key a name – I chose yehuda1491-sky-key.
  • Click the ‘Create Access Key’ button.
  • Be sure to copy your secret key.

At this point the Spaces configuration is done, now on to configure the Bluesky PDS to use the CDN.

Bluesky PDS Configuration

  • Login to your VPS
  • Use sudo if needed
# cd /pds
# vi pds.env
  • Comment this existing line out
# PDS_BLOBSTORE_DISK_LOCATION=/pds/blocks
  • Insert and edit the following
# Add to the end of file
# DO Spaces
# Replace fake access and secret keys with yours
PDS_BLOBSTORE_S3_ACCESS_KEY_ID=Your_ID
PDS_BLOBSTORE_S3_SECRET_ACCESS_KEY=Your_Secret_Key
# Replace endpoint and bucket with yours
PDS_BLOBSTORE_S3_ENDPOINT=https://sfo3.digitaloceanspaces.com
PDS_BLOBSTORE_S3_BUCKET=yehuda1491-sky
# No configuration needed
PDS_BLOBSTORE_S3_REGION=auto
PDS_BLOBSTORE_S3_FORCE_PATH_STYLE=true
PDS_BLOBSTORE_S3_UPLOAD_TIMEOUT_MS=60000
# This is probably already in the .env but if it isn't, add it
# PDS_BLOB_UPLOAD_LIMIT=52428800
  • Save & exit vi
  • Back at the command line, run for the changes to take effect
# docker compose up -d
  • Restart the service
# systemctl restart bluesky-pds

And that’s it!

Mvto!
-Yehuda