自定義域名A記錄到 Github 的IP時,Github怎麼知道我的 Github page 是哪一個?

今天用 Octopress 在 Github Page 搭建博客,在自定義域名的時候,讀了 Github 的文檔:

With your DNS provider, create A records that resolve to the following IP addresses:
192.30.252.153
192.30.252.154

它的意思應該是把 A 記錄指向上述兩個IP,我的疑問是:

我僅僅把域名解析到上面的IP,Github 的伺服器怎麼判斷我的 Github Page 是哪個?

例如我的自定義域名是:http://example.com,我的 Github Page 是:http://username.github.io

當輸入http://example.com時,DNS解析到 192.30.252.153,伺服器怎麼知道我要去的是 http://username.github.io? 畢竟 Github Page 有千千萬萬個。


試了一下重複的CNAME, 會收到gitbub的提醒郵件,然後有個鏈接,


https://help.github.com/articles/my-custom-domain-isn-t-working/#cname-already-taken


會看到以下內容:

CNAME already taken

If the custom domain in your CNAME file is being used by another GitHub Pages site, you will receive a page build warning.

If you have an an apex domain such http://asexample.com in your CNAME file, this means that either http://example.com or its www subdomain (http://www.example.com) has been used in a CNAME file in another repository and is being used by the corresponding GitHub Pages site.

If you have a www subdomain such http://aswww.example.com in your CNAME file, this means that either http://www.example.com or its apex domain (http://example.com) has been used in a CNAME file in another repository and is being used by the corresponding GitHub Pages site.

To use your custom domain, whether you"re setting up an apex domain or a subdomain, you need to remove the CNAME file from the other repository in which it"s used. After you have done this, you will also need to push again to trigger a new page build.

If you don"t own the other repository containing the CNAME file where your custom domain is in use, you should try to contact the owner of the other repository and ask them to remove the CNAME file. If you don"t know which other repository contains the CNAME file where your custom domain is in use, you can contact GitHub support for help.


http請求頭裡面有帶域名的,用以區分你訪問的是哪個域名。


你的github pages 倉庫有一個cnam文件用於記錄你的自定義域名A。
訪問域名A會通過DNS 解析到github的伺服器IP,不過你的http頭上記錄的域名還是A,github的伺服器會根據該域名找到對應的倉庫。


如果已經有這個CNAME了 他會提示你聯繫設了這個CNAME的人 或者讓客服幫你
在這時推薦一下我的個人博客 基於github page
http://bodyno.com/


不是需要你自己建立個 CNAME 文件么。。


怎麼解析github自己的網址啊,


第一步:在你的repo下新建一個cname文件,並在其中寫入你的域名。
第二步:在你的dns提供商那給域名添加一個cname記錄,指向[username].http://github.io


非常感謝,我第一次弄得時候就是沒有解析192.30.252.153導致無法打開博客。 幫了我大忙


當初就是看到了樓主這體溫,一語點醒夢中人吶,回來補個贊[大拇指] -0-


http頭裡面有域名


推薦閱讀:

【DNS哪個好】速度快 穩定?
public DNS是如何解決CDN分發的問題的?
114.114.114.114 的 DNS 靠譜嗎?
Google Public DNS在大陸有伺服器了?
Google是如何拿到8.8.8.8和8.8.4.4這兩個IP地址的?

TAG:編程 | 計算機網路 | DNS |