1

I have created two CNAMEs for my (CloudFront) domains, like this:

enter image description here

nslookup works, giving me the correct values for both www and d-test — but when I actually get the data, using curl or a browser, all data is retrieved from the origin pointed to by www, regardless of which URL I actually use. If I use the origin URLs, it works fine.

How is this even possible?

4
  • domaincontrol name servers are owned by GoDaddy but CloudFront is an Amazon product. It looks like you are either creating CNAME records in the wrong DNS system or you are confused about where your DNS is hosted. – Stephen Ostermiller Nov 27 '20 at 17:01
  • If you gave the real name involved people could provide relevant help. Otherwise... – Patrick Mevzek Nov 27 '20 at 18:23
  • @StephenOstermiller — your first sentence is correct (except for the word “but”, which should be “and”). My domain name is hosted by GoDaddy and I wish it to point at CloudFront. The only issue was the wildcard in the CNAME I specified in CloudFront. – Malvolio Nov 27 '20 at 20:42
  • @PatrickMevzek — thanks for the offer to help, but as you can see in my own answer, the act of typing out the question revealed the problem. – Malvolio Nov 27 '20 at 20:43
3

The greatest benefit I derive from StackExchange is that asking the question forces me to state the problem in detail.

In this case, I through in the parenthetical “(Cloudfront)” solely for completeness, but then I thought, “Hey...”

Yes, turns out, when I set up the Cloudfront distribution for www (weeks ago) I specified the “alternative CNAME”, as “*.mydomain.com” of course.

The two CNAMEs resolved to two different Cloudfront distributions, but then AWS read the HOST header in the HTTPS request, to choose which distribution to use, so it was sending all traffic to the www one, because it had the wildcard.

Correcting the two “alternative CNAME” settings on the distributions, to "www" and "d-test" respectively, fixed the problem.

(I have added the amazon-cloudfront tag to the question to help anyone with the exact same problem to find it, but presumably other CDNs work the same way.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.