*)squid正向代理
1.安装
yum install squid -y
2.开启服务
systemctl start squid
netstat -anlpe | grep squid
vim /etc/squid/squid.conf
http_access allow all ##允许所有ip访问
cache_dir ufs /var/spool/squid 100 16 256 ##最大缓存带小为100m 以及目录16 二级目录256
测试
打开浏览器,点击Edit-----preferences-----Network-----Settings-Manual proxy configuration 填写真机ip和port-----Use this proxy server for all protocols-----ok
*)squid反向代理
加速
1.安装
yum install squid -y
2.开启服务
systemctl start squid
netstat -anlpe | grep squid
3.配置文件
vim /etc/squid/squid.conf
59 http_port 80 vhost vport
60 cache_peer 172.25.254.157 parent 80 0 no-query originserver
4.重启服务
systemctl restart squid
测试
在真机 vim /etc/hosts
172.25.254.157 www.westos.com
*)轮叫机制
vim /etc/squid/squid.conf
http_port 80 vhost vport
cache_peer 172.25.254.157 parent 80 0 no-query originserver name=web1 round-robin weight=1 ##出现一次
cache_peer 172.25.254.157 parent 80 0 no-query originserver name=web2 round-robin weight=3 ##出现三次
cache_peer_domain www.westos.com web1 web2
systemctl restart squid