Squid + DNS配置CDN加速服务器(概念篇)

Squid + DNS配置CDN加速服务器(概念篇)


实验要求:

iptables -F

selinux = disable


squid 主节点:192.168.122.139

squid 从节点:192.168.122.15

正向解析:数据从服务器的集群里出去,访问了互联网。

方向解析:数据从互联网请求访问我们的服务器集群



Squid(反向解析):

squid各参数详解:

http://www.visolve.com/squid/squid26/network.php

squid配置介绍:

http://old.squid-cache.org/Doc/Users-Guide/detail/accel.html



1.单向配置:

squid主节点上(192.168.122.139):

http_access allow all

http_port 80 transparent #transparent Configure Squid as transparent proxies

#这个地方设置80端口由squid监听,所以apache默认的监听端口需要改动

cache_peer 192.168.122.15 parent 80 0 no-query originserver

#这里指定了所有访问80端口的数据包请求全部都移交到192.168.122.15这台服务器的80端口上,即访问转接。


测试:

firefox访问192.168.122.139可以看到192.168.122.15上的发布页面(192.168.122.15apache的默认发布下写index.html文件)

2.缓存加速和远程代理(子邻居)

http_port 80 accel vhost vport #accel Configure Squid in accelerator mode

cache_peer 192.168.122.19sibling 80 3130

#这里定义了192.168.122.139的邻居,如果本地服务器没有资源再通过ICP查询去其邻居中取得缓存,sibling定义了同级服务器。

cache_peer 192.168.122.19 parent 80 0 no-query originserver round-robin name=web2

cache_peer 192.168.122.139 parent 8080 0 no-query originserver round-robin name=web3

#这里设定了apache的端口为8080,在httpd.conf文件里面换了apache的监听端口

cache_peer_domain web2 web3

#这个顺序先后决定了先访问谁。


测试:

firefox访问192.168.122.139可以看到web3上的发布页面

3.缓存加速和远程代理(父邻居)

http_port 80 accel  vhost vport

cache_peer 192.168.122.19parent 3128 3130

cache_peer 192.168.122.19 parent 8080 0 no-query originserver round-robin name=web2

cache_peer 192.168.122.139 parent 8080 0 no-query originserver round-robin name=web3


(sibling是子级,parent是父级。cache_peer邻居分为parent(父邻居),sibling(子邻居).parentsibling的区别在于父邻居能为 子 cache 转发丢失的Cache,而子邻居不可能.


说明:

(1)命令cache_peer 的定义格式是:

cache_peer hostname type 3128 3130

hostname是用来指定获取缓冲的PROXY 主机的名字

typePROXY主机的类型,有以上PARENT SIBLING 两种

3128:HTTP_PORT

3130:ICP_PORT


(2)附加配置选项(注意应为小写,配置时)

NO-QUERY:不做查询操作,直接获取数据

NO-NETDB-EXCHANGE:代理服务器之间不交互信息

NO-DIGEST:代理服务器之间不做摘要表查询,直接用ICP 协议沟通(同级代理)

PROXY-ONLY:直接获取对方缓冲,转交给代理服务器的客户端,而不存入本地

ROUND-ROBIN:如果设置数部上层服务器,那么轮流查询父级服务器

LOGIN=USER:PASSWD:要求对方做帐号及密码验证,例如

cache_peer 192.168.1.41 sibling 3128 3130 login=kao:123456


4.基于不同域名的squit的访问:

http_port 80 accel  vhost vport

cache_peer 192.168.122.19 sibling 80 3130

cache_peer 192.168.122.19 parent 80 0 no-query originserver round-robin name=web2

cache_peer 192.168.122.139 parent 8080 0 no-query originserver round-robin name=web3

cache_peer_domain web2 www.westos.com

cache_peer_domain web3 image.westos.com


测试:

firefox分别访问www.westos.comimage.westos.com


5.访问控制:

acl  ip src 192.168.122.0/24

...

http_port 80 accel  vhost vport

cache_peer 192.168.122.19 sibling 80 3130

cache_peer 192.168.122.19 parent 80 0 no-query originserver round-robin name=web2

cache_peer 192.168.122.139 parent 8080 0 no-query originserver round-robin name=web3

cache_peer_access  web2 allow ip

cache_peer_access  web3 deny ip

cache_peer_domain web2 www.westos.com

cache_peer_domain web3 image.westos.com




Options Functions

accel Configure Squid in accelerator mode

transparent Configure Squid as transparent proxies

vhost Accelerator using virtual hosts

vport Accelerator with virtual ip host support

vport=NN As above, but uses specified port number rather than the http_port number.

defaultsite=xx Main web site name for accelerators. also implies accel option

protocol= Protocol to reconstruct accelerated requests with. Defaults to http.



网上文档可参考:

http://zhumeng8337797.blog.163.com/blog/static/10076891420118954728980/

any question

mail:doushaisme@qq.com


转载于:https://my.oschina.net/u/1759688/blog/270389

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值