Keywords: Drupal - AWS - Technical issue - Other
I have tried with multiple different Bitnami LAMP stacks (Drupal 7.67) but not been able to get a site working behind AWS Cloudfront.
The error is always "Too many redirects" etc.
Week ago I started to build my own LAMP stack from a Ubuntu 18.04 AMI.
I installed all needed components to run Drupal 7 and 8 and then decided to try to put Cloudfront in front of the a site. And it worked!
For this reason, I have to stop using Bitnami stacks, because there has to be some setting (maybe related to security or Apache or anything) which prevents Cloudfront to work.
And I do not mean a Drupal CDN module, but I mean that the whole domain is pointed to cloudfront. I am able to run the site fully behind cloudfront either using a ALB or just the EC2 instance. In case using ALB, the CF origin is the Load Balancer DNS name, if using EC2 the origin is the EC2 end point. Always the domain is pointed to cloudfront DNS. Also the SSL cert has to be set in the Cloudfront settings and "Viewer Protocol Policy" "Redirect HTTP to HTTPS"
To be more specific, the most important setting in the CF (and which breaks the Bitnami stack) is the
"Cache Based on Selected Request Headers". If you set this to "All" the cloudfront does not cache anything, and this works also with Bitnami stack but then nothing is cached. But if you set this to "white list" and select "host" and "origin" then the Bitnami stack does not work anymore, but my new LAMP stack works. So some setting in the Bitnami stack prevents this to work which I do not have in the new stack.
Please let me know what setting should I remove from Bitnami LAMP stack to be able to use cloudfront fully.