blog.zhuohua.store's Archiver

admin 发表于 2019-9-9 22:24

Squid反向代理+轮询(一)

[attach]6862[/attach]


目的:
使用Squid轮询,让客户端轮流对后台的两台Web服务器(192.168.168.154:80、192.168.168.135:88)进行访问Web访问

安装squid:
[root@localhost ~]# yum -y install squid

[root@localhost ~]# squid -v
Squid Cache: Version 3.1.23

启动squid:
[root@localhost ~]# service squid start
[root@localhost ~]# chkconfig --level 35 squid on


Squid 的主配置文件
[root@localhost ~]# vi /etc/squid/squid.conf

文件开头插入:
http_port 80 vhost vport
接着插入后台站点信息:(轮询配置;后台服务器的Web端口可以自定义的)
cache_peer 192.168.168.154 parent [color=Red]80[/color] 0 originserver round-robin weight=1
cache_peer 192.168.168.135 parent [color=Red]88[/color] 0 originserver round-robin weight=1
[attach]6863[/attach]


插入: httpd_suppress_version_string on
[attach]6864[/attach]


修改: http_access allow all
[attach]6865[/attach]


修改: http_port 80
[attach]6866[/attach]




保存文件后,重启squid服务:
service squid restart



防火墙配置:
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables-save > /etc/sysconfig/iptables






测试:
因使用Squid 的round-robin,所以客户端的访问将轮询两台web服务器,浏览器采用 "Ctrl + F5" 来深度刷新测试。
备注:只对Squid代理服务器192.168.168.130进行访问,端口为Squid所使用的端口

[attach]6867[/attach]


[attach]6868[/attach]


笺注:

测试中,两台后台服务器的确出现了有序的轮询,一个客户端在两台后台Web服务器之间也会不断地切换;这种模式不适合一般的Web访问。

假如有一台后台服务器不能提供Web服务,另外一台会支持全部Web服务;实验中,只要还有一台后台服务器正常运行,客户端都没有看到有Web服务访问失败。当出现故障的后台服务器恢复后,也会立刻加入轮询。

两台后台服务器都不需要为Squid轮询做任何额外的操作。





相关文章:
[url=http://blog.zhuohua.store/viewthread.php?tid=69&extra=page%3D1]Squid反向代理+轮询(二)[/url]
[url=http://blog.zhuohua.store/viewthread.php?tid=423&page=1&extra=#pid851]CentOS8_Squid反向代理+轮询(一)[/url]





#################################
#################################
[url=https://weidian.com/?userid=823531601&wfr=wx&sfr=app&source=shop]亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^[/url]

[url=https://weidian.com/item.html?itemID=905482571143024037958&wfr=wx&sfr=app&source=goods_home]苏泊尔多功能电热锅韩式电火锅8-10人家用电炒锅不粘锅电锅电烤锅[/url]
[url=https://weidian.com/item.html?itemID=905482571143024037958&wfr=wx&sfr=app&source=goods_home][attach]7086[/attach][/url]

[url=https://weidian.com/item.html?itemID=905482571143024040619&wfr=wx&sfr=app&source=goods_home]苏泊尔电火锅多功能家用电热锅不沾锅一体电煮锅宿舍4-6人[/url]
[url=https://weidian.com/item.html?itemID=905482571143024040619&wfr=wx&sfr=app&source=goods_home][attach]7087[/attach][/url]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.