问题原文
原帖链接 · Michael Lorton · CC BY-SA 4.0
I have created two CNAMEs for my (CloudFront) domains, like this:
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?
已采纳解答
原帖链接 · Michael Lorton · CC BY-SA 4.0
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.)
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
