大网数据广告活动
网站运营与故障问答

CNAME works for nslookup but not curl

· 52CE 我爱测

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 or…

问题原文

原帖链接 · 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.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。