OctoberCMS + Cloudfront domain issues

OctoberCMS + Cloudfront domain issues

After taking a site live we noticed that clicking any link on the site would switch from our domain to the domain of the ELB. The original hostname was not being passed to OctoberCMS. While we could probably hard code the hostname into an environment variable somewhere, I figured there is probably a configuration somewhere in Cloudfront that would make this work properly.

In this scenario we have Cloudfront, then the load balancer, then our EC2 instance. After realizing the issue was Cloudfront not passing the hostname I was able to find a solution on ServerFault. All you need to do is whitelist the “Origin” and “Host” headers in the Cloudfront behavior. If you have multiple behaviors setup you will need to do this for each.

AWS_CloudFront_Management_Console

Cloudfront settings

Short URL: http://bit.ly/2vHxGq1

Leave a reply