Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Last active April 4, 2019 17:18
Show Gist options
  • Save ugisozols/6778058 to your computer and use it in GitHub Desktop.
Save ugisozols/6778058 to your computer and use it in GitHub Desktop.
Refinery CMS + Dragonfly + Amazon S3 + Amazon Cloudfront
# config/environments/production.rb:
config.action_controller.asset_host = "http://cdn%d.example.com"
# config/initializers/refinery/images.rb:
config.dragonfly_url_format = "/images/:job/:basename.:ext"
if Rails.env.production?
config.dragonfly_url_host = "http://cdn4.example.com"
end
# config/initializers/refinery/resources.rb:
config.dragonfly_url_format = "/resources/:job/:basename.:format"
if Rails.env.production?
config.dragonfly_url_host = "http://cdn5.example.com"
end
----------------------
Configure 2 Amazon Cloudfront distributions:
1st pointing to S3 bucket and configured with these CNAMES: cdn0.example.com,
cdn1.example.com, cdn2.example.com and cdn3.example.com
2nd pointing to your site (in this example - example.com) because Dragonfly
generates thumbnails on the fly. This distribution is also configured with
these CNAMES: cdn4.example.com, cdn5.example.com
@caherrerapa
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment