CloudFront Dynamic Content & Apache using Multiple Virtual Hosts

amazon ec2amazon-cloudfrontamazon-elbapache-2.2

I've tried to setup CloudFront to point to an Elastic Load Balancer.

I can see the requests are reaching the web server (which as multiple Virtual hosts configured) however the requests always end up at the /var/www/error/noindex.html page.

If I remove CloudFront from the www DNS the sites work fine on apache though the ELB.

Also I have the CName www for each domain setup.

Any thoughts on why these CloudFront requests would arrive at the error page?

thx

Best Answer

Cloudfront currently doesn't have the ability to pass the Host header back to the origin. Instead it passes the host specified in the Cloudfront distribution's origin field. So while viewing a page through ELB will properly pass the host name you provide in your browser back to your web instance (thus bringing up the correct virtual host), the same request made through Cloudfront through to ELB and on to your web instance will arrive at the web instance with the host name of the ELB. I know, frustrating.

They know about it (as of writing this); hopefully it's fixed soon:

https://forums.aws.amazon.com/thread.jspa?threadID=84588