Using Amazon Cloudfront CDN with Rails 188.8.131.52 App
Learn how to setup CDN using Amazon Cloudfront for Rails 184.108.40.206 Apps.
Go to Amazon Cloud Front and setup a CDN distribution. Click Cloud Front, provide the hostname
and accept the default values for other values. It will take about 15 to 30 minutes for the changes to take effect.
production.rb add :
config.action_controller.asset_host = "amazon-provided-id.cloudfront.net"
You can also setup a CNAME like cdn.yourdomain.com to point to amazon-provided-id.cloudfront.net. I am using https for the entire site. Since I did not have wildcard SSL certificate, it did not work. So, I am using
https://amazon-provided-id.cloudfront.net for now.
After deploying your Rails app, view the page source. Verify the CDN. You should now see CDN for static assets. Something like this:
https://d1b5oz78c0udqh.cloudfront.net/assets/application-b5f55fdfb705b0fcdb2b9f6d9c28e97d.js https://d1b5oz78c0udqh.cloudfront.net/assets/application-78676f382b46d6507c553c905c652a11.css https://d1b5oz78c0udqh.cloudfront.net/assets/logo_300w-401a078fda85ae7672f3e18f1d8f9cfd.png