Search code examples
amazon-web-servicesamazon-elastic-beanstalkamazon-cloudfrontamazon-route53

Why is CloudFront working via one CNAME record but not another?


So assume company name is widget

I have elastic beanstalk instance at widget.elasticbeanstalk.com I have a domain name widget.com under Route53 control I have a CNAME record direct.widget.com pointing to widget.elasticbeanstalk.com I have another CNAME record search.widget.com also pointing to widget.elasticbeanstalk.com

This works fine I can access my eb instance via search.widget.com and direct.widget.com

I then setup Cloudfront to use origin direct.widget.com with alternate domain name of cache.widget.com, and I configure another CNAME on Route53 from cache.widget.com to my cloudfront instance (lets call this drvevtora80lk.cloudfront.net)

This also works fine I can access my Cloudfront instance via cache.widget.com and this will recognise already cached data and work or go to direct.widget.com as necessary.

But my users are using search.widget.com and I want them to now go via Cloudfront rather than directly to the server. So I now modify the search.widget.com CNAME to point to drvevtora80lk.cloudfront.net and wait a while for changes to propogate.

But now using search.widget.com gives me a Cloudfront error

The cache.widget.com and direct.widget.com continue to work fine, what am I doing wrong ?


Solution

  • The problem was that although I modified the search.widget.com CNAME to point to drvevtora80lk.cloudfront.net I forgot to add search.widget.com as an alternate name within my Cloudfront distribution, adding that and it now works.