2017年7月27日 星期四

無法在 GoDaddy 設定 @ 的 CNAME

因為網站是用 WordPress 架在 AWS 上,所以網域應該要用 CNAME 導去 AWS 的位址
本來很單純想說網域(假設是 example.com)想要自動轉去 https://www.example.com
設定上就是加上 @ 的 CNAME
但結果在 GoDaddy 上就是無法設定,它一直顯示紀錄已存在。

花了一些時間查詢以後,雖然細節有點看不太懂,不過總之原因好像是因為 CNAME 其實會跟其他像是 TXT、MX 之類的紀錄重疊 [1-2]
所以某個網域或者子網域如果要設定 CNAME 的話,這個網域或子網域應該要不存在任何除了 A 以外的紀錄
否則會導致紀錄之間衝突,因而產生像是 [3] 的結果,某些既存的其他服務會因為被 CNAME 覆蓋而無效了。

另外 [2] 的回覆也有提到,DNS 的規格文件 RFC 1034 的 3.6.2 小節中,有以下的具體描述。

A CNAME RR identifies its owner name as an alias, and specifies the corresponding canonical name in the RDATA section of the RR.  If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different.  This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types.

而這個問題要解決的話,以 GoDaddy 來說,可以去設定它免費提供的「網域轉址」
就可以把網域(example.com)自動導向到某個自行指定的網址了。
不過實際實驗時,好像網域轉址只對 HTTP 有效,HTTPS 似乎無效就是了。
也就是說,設定後 http://example.com 會有自動轉址的效果,但是 https://example.com 則沒有反應。

參考資料
  1. Configuring “@” CNAME record in GoDaddy control panel
  2. CNAME and TXT record for same subdomain not working
  3. Why it's a bad idea to put a CNAME record on your root domain
  4. RFC 1034

沒有留言: