Using a custom Domain Name for CloudFront CDN
Credit a CNAME in your DNS record, pointing to your CloudFront domain name.
CNAME cdn d111122223333.cloudfront.net 300
Login to your AWS Console and edit your CDN distribution. Add the custom domain name and save the setting.
Next, edit your rails environment file and change the asset_host to your custom domain.
config.action_controller.asset_host = 'https://cdn.calvin.my'
Note that if you are using https, you will need to submit your SSL cert to cloudfront. The cert needs to be issued by a trusted CA, no self-signed cert is allowed. Check here for more information.
Finally, reboot your Nginx server. Now your assets will be served from your custom domain, which is a CNAME alias of the CloudFront domain.
AI Summary
Chrome On-device AI
2024-12-06 19:33:36
Share Article