squid for WIN + DNSPOD 搭建CDN服務器手記

 轉載於落伍.需要的兄弟好好研究..!~

呵呵,今天沒事做,學了下搭建CDN,先用公司的一個域名試了一下,成功.www.uduu.sh.cn
說名一下,www.uduu.sh.cn主服務器IP爲61.129.33.42爲上海電信
因爲中國網絡問題,一些網通用戶訪問速度較慢,
所以,我選擇了用大連網通服務器做CDN,服務器IP爲218.61.10.172
也就是
主服務器:61.129.33.42
CDN服務器:218.61.10.172

首先下載squid for windows安裝包 squid-2.7.STABLE5-bin.zip
然後解壓縮,放到C盤squid目錄內.
進入目錄C:\squid\etc內,將所有文件的.default全部刪掉
編輯下squid.conf,將所有內容刪掉,替換以下內容,並保存


http_port 80 vhost vport=80
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
cache_mem 1024 MB
maximum_object_size 4096 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 256 KB
cache_dir ufs c:/squid/var/cache 40960 16 256
cache_swap_low 80
cache_swap_high 97
strip_query_terms off
request_body_max_size 5 MB
memory_pools on
memory_pools_limit 50 MB
access_log none
cache_log none c:/squid/var/logs/cache.log
cache_store_log none
pid_filename c:/squid/var/logs/squid.pid
hosts_file C:\WINDOWS\system32\drivers\etc\hosts
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i .gif 180 20% 10080 override-expire ignore-reload reload-into-ims
refresh_pattern -i .jpg 180 20% 10080 override-expire ignore-reload reload-into-ims
refresh_pattern .                           120  50%    1440
acl all src 0.0.0.0/0.0.0.0
acl p-manager proto cache_object
acl s-localhost src 127.0.0.1/255.255.255.255
acl d-localhost dst 127.0.0.0/8
acl d-domains dstdomain .uduu.com
acl d-domains dstdomain www.uduu.sh.cn
acl p-ssl  port 443 563
acl p-safe port 80 443 563
acl m-conn method CONNECT
acl m-purge method PURGE
acl n-maxconn maxconn 15
http_access allow p-manager s-localhost
http_access allow m-purge
http_access allow  !p-safe
http_access deny  m-conn !p-ssl
http_access deny  n-maxconn
http_access allow p-manager
http_access allow d-domains
http_access allow all
http_reply_access allow all
acl r-url urlpath_regex realtime
cache deny r-url
icp_access allow all
follow_x_forwarded_for allow all
acl_uses_indirect_client offrange_offset_limit -1
dns_timeout 2 seconds
forward_timeout 10 seconds
connect_timeout 10 seconds
peer_connect_timeout 6 seconds
read_timeout 10 seconds
request_timeout 6 seconds
persistent_request_timeout 16 seconds
cache_mgr webmaster@uduu.net
cache_effective_user nobody
cache_effective_group nobody
visible_hostname www.uduu.sh.cn
logfile_rotate 0
always_direct allow all
#error_directory /usr/local/squid/share/errors/Simplify_Chinese
coredump_dir c:/squid/var/cache
access_log c:/squid/var/logs/access.log squid
cache_log  c:/squid/var/logs/cache.log
cache_store_log  c:/squid/var/logs/store.log

打開目錄c:\squid\var
新建兩個目錄,分別爲cache和logs

打開CMD,進入c:\squid\sbin目錄,執行squid -i 將SQLUID寫入服務項
初始化cache目錄squid -z 如果配置文件出錯的話,初始化cache目錄將會出錯。
關閉或禁用IIS
在服務裏面運行squid
———–到這裏,squid部分就搭建成功了

下面開始做域名解析.
打開目錄C:\WINDOWS\system32\drivers\etc
用記事本打開hosts編輯並保存
61.129.33.42 www.uduu.sh.cn uduu.sh.cn

DNSpod大家都會用啦,
把域名NS服務器換到DNSpod上來
然後將電信IP指向61.129.33.42
將網通IP指向218.61.10.172
等A記錄生效……..

生效後,首次打開網站速度可能會慢,或者出錯吧,二次訪問後速度就會飛快啦,呼呼~~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章