windows 2003配置squid做CDN节点

squid 下载地址 http://squid.acmeconsulting.it/

把压缩包直接解压到C盘即可。目录是 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 128 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 200 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 //hosts文件位置,windows都是这个,不需要改动。
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 www.oiplay.com //这里填要缓存的域名。域名不多的话直接直接在这里写就行,每行一个域名,格式都照这一条就成。如果实在多,可以列成一个文本文件 如c:/squid/domain.txt 然后所有域名都放里面,每行一个域名。我这里填的是只有这一个域名,如果需要所有二级域名都可以访问的话,可以用 .oiplay.com即包括了所有二级域名。
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 admin@oiplay.com  //联系邮箱,出现错误时会有提示。
cache_effective_user nobody
cache_effective_group nobody
visible_hostname cdnhk  //节点名称,如果多个节点的话,比较容易分出是哪个节点。
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

写完配置文件后,保存。

运行-CMD
cd c:\squid\sbin 进入c:\squid\sbin 目录
执行
squid -z //配置cache目录
squid -i //写入windows 服务
好了,可以到管理工具>服务里,启动squid了。

下面开始做域名解析.
打开目录c:\windows\system32\drivers\etc
用记事本打开hosts编辑并保存
...(ip地址是指你目标站的ip地址)   www.oiplay.com

文章评论已关闭