squid代理服务器又名正向/反向VPN,是客自主设定的代理服务器,通过代理服务器可以使不能上网的主机上网,和互联网通信。
实验一:配置squid代理服务器(正向VPN)
1、实验环境
两台主机,一台客户端,另一台squid代理服务器,并且squid可以上网,客户端不能上网
2、实验目的
配置squid正向代理服务器
3、实验流程
squid代理服务器:
yum install squid
systemctl start squid
systemctl enable squid
netstat -antlupe | grep squid
vim /etc/squid/squid.conf
改56行和62行
允许别人把我当作代理服务器,缓存100M,要定期自动清理,16个一级目录,256个二级目录
systemctl restart squid 重启服务
客户端:
在浏览中添加代理服务器信息
172.25.254.222 3128 端口
客户端通过172.25.254.222的3128端口和外部通信
实验二、cdn加速
1、实验环境
三台主机:client主机 ,squid反向代理服务器,server服务器
2、实验原理
squid反向代理服务器从server服务器中缓存数据,方便client主机访问,加快访问速度,减轻服务器压力。
3、实验流程
server服务器:
yum install httpd 安装apache服务
systemctl start httpd 开启apache
systemctl stop firewalld 关闭防火墙
cd /var/www/html
ls
vim index.html 编辑发布文件
<h1>shenzhen's page</h1>
systemctl restart httpd 重启apache服务
squid反向代理服务器:
vim /ect/squid/squid.conf编辑squid代理文件
http_port 80 vhost vport 利用80端口访问apache的资源,写入apache的虚拟主机和虚拟端口
cache_peer 172.25.254.211 parent(父级) 80(apache服务) 0(此台代理服务器没有合作伙伴 proxy-only
systemctl restart squid 重启服务
client客户端
vim /etc/hosts
(写入代理服务器的ip)www.westos.com
测试:
ping www.westos.com
在浏览器中访问代理服务器ip地址
实验三、调度代理服务器
1、实验环境
一台客户端主机
一台调度代理服务器
两台配有apache服务的服务器
2、实验原理
通过代理调度器调度服务器集群,降低服务器负载
3、实验流程
服务器:
做好apache服务配置详细情况访问如下
https://blog.youkuaiyun.com/SS_CC_Go/article/details/90478851
调度器配置:
1、yum install squid 下载代理软件
2、vim /etc/squid/squid.conf
http_access allow all 允许http访问
http_port 80 vhost vport 开放80端口
cache_peer 172.25.254.1 parent 80 0 proxy-only no-query round-robin originserver name=web1
第一个服务器
cache_peer 172.25.254.2 parent 80 0 proxy-only no-query round-robin originserver name=web2 weight=2
第二个服务器
cache_dir ufs /var/spool 100 16 255
开放缓存目录
3、systemctl restart squid 重启服务