Using Rails ActiveStorage with DigitalOcean Spaces CDN Custom Subdomain?

April 13, 2019 555 views
Ruby on Rails CDN DigitalOcean Ubuntu 18.04

I'm working on setting up a custom subdomain for my site's Spaces CDN and was wondering if anyone has any advice on how to get my Rails app to actually return the custom subdomain URL for images instead of the domain.

My images are being loaded from{a_bunch_of_other_metadata}, despite my CDN being set up with a subdomain of

I have this in my config/storage.yml (it's called amazon but it's really DO Spaces):

  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:digitalocean, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:digitalocean, :secret_access_key) %>
  region: sfo2
  bucket: vglist
  endpoint: ''

I tried changing the endpoint but that didn't seem to work. The custom subdomain is set up and everything, I just need to configure Rails and ActiveStorage to actually use it.


1 Answer

Any update? I want to use Space CDN, but I cann't find the way to change the url to CDN address.

Have another answer? Share your knowledge.