Using the new ActiveStorage proxying feature to pull files from a CDN?

I asked this question a while ago in the DO Community forums, so feel free to reference this for more context: Using Rails ActiveStorage with DigitalOcean Spaces CDN Custom Subdomain? | DigitalOcean

I use DigitalOcean Spaces (which is API-compatible with S3) for my Rails app vglist and I’m on Rails 6.1 now. I’d like to use DigitalOcean’s Spaces CDN to load files from my site more quickly, but I’m not sure how exactly to accomplish that.

Essentially, now that proxying is supported, is there a way to use DigitalOcean Spaces’ CDN route for loading images in my Rails app? e.g. if I have a file at variants/f0wiz0ls64m8h5mhkgcxzu9ryvsd/9fb35d14726f288d319bd1b72e02e094325db77ef3d2a0dacf673d0fc7673672, rather than loading an image from https://vglist.sfo2.digitaloceanspaces.com/FILEPATH, I’d load it from https://cdn.vglist.co/FILEPATH.

Is there a way to do that while still uploading the files to the endpoint https://vglist.sfo2.digitaloceanspaces.com? Or is this not supported by the proxying feature?

Sorry I’m misunderstanding what proxying is intended for! If there’s another solution for this problem, I’d appreciate anyone who can point me in the right direction for it.

Thanks :slight_smile:

@connorshea Were you able to figure out a solution to this? I’m working on the same issue and haven’t found solid instructions for using the Spaces CDN with Rails Active Storage proxying.

DigitalOcean released a guide that resolved this for me, here:

Thanks for sharing this article this is very useful.