在七牛雲CDN新建域名的時候,七牛雲要求做源站測試,該表單如下圖所示:
#這個圖片路徑我確定是OK的,因為後面在跟七牛雲客服溝通的過程中,他告訴我“您的伺服器不讓host是加速域名的請求訪問,返回404”,如下所示:
$ curl -I "http://www.dgcomet-cms.dgcomet.com/static/img/6bb80da2c2d4045f7173d41 305709832.jpg" -H "Host:cn.dgcomet-cms.dgcomet.com"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HT TP/1.1 404 Not Found
Date: Wed, 24 May 2017 10:28:05 GMT
Server: Apache/2.4.23 (Unix) PHP/5.6.8
Content-Type: text/html; charset=iso-8859-1
而如果不帶這個Host,則是正常的:
$ curl -I "http://www.dgcomet-cms.dgcomet.com/static/img/6bb80da2c2d4045f7173d41 305709832.jpg"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 82935 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HT TP/1.1 200 OK
Date: Wed, 24 May 2017 10:27:42 GMT
Server: Apache/2.4.23 (Unix) PHP/5.6.8
Last-Modified: Wed, 24 May 2017 07:51:25 GMT
ETag: "143f7-550405ef9e6a0"
Accept-Ranges: bytes
Content-Length: 82935
Content-Type: image/jpeg
我的伺服器是阿里雲ECS,用的apache,請問要怎麼配置才能讓這加了Host:cn.dgcomet-cms.dgcomet.com
的請求能夠通過呢?
嗯,找到方法了,原來也很簡單。
我本來就在用apache的vhost的,把加速域名添到源站域名對應的vhost項下的ServerAlias就OK了