問題描述
瀏覽自己Github某倉庫的README.md內時,發現文檔的圖片始終加載不出,打開瀏覽器后臺,冒出一片紅,Failed to load resource: net::ERR_CONNECTION_RESET
,如下圖所示:
問題分析
可能造成這問題的原因:
- DNS污染
- host設置錯誤
- …
解決方法
主要思路就是使用本地hosts文件對網站進行域名解析,一般的DNS問題都可以通過修改hosts文件來解決,Github的CDN域名被污染問題也不例外,同樣可以通過修改hosts文件解決,將域名解析直接指向IP地址來繞過DNS的解析,以此解決污染問題。
主要做法是用文本編輯器打開C:\Windows\System32\drivers\etc\hosts
,在文件末尾處添加
# GitHub Start192.30.253.112 github.com
192.30.253.119 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com# GitHub End
參考文獻
【最新】解決github圖片不顯示的問題