安装服务
yum install squid -y打开服务
systemctl start squid查看打开结果
netstat -antlupe|grep 3128修改配置文件/etc/squid/squid.conf
# And finally deny all other access to this proxy http_access allow all # Squid normally listens to port 3128 http_port 3128 # Uncomment and adjust the following to add a disk cache directory. cache_dir ufs /var/spool/squid 100 16 256重启服务
systemctl restart squid配置代理 选择edit的preferences 选择网络选项 选择setting,配置IP地址以及端口 利用客户机上网,验证配置结果
编辑主文件
echo "Hello World">/var/www/html/index.html访问结果
编写配置文件/etc/squid/squid.conf
# And finally deny all other access to this proxy #允许其他主机的访问 http_access allow all # Squid normally listens to port 3128 http_port 80 vhost vport #指定使用端口 #指定父级主机,同时指定模式为仅代理模式 cache_peer 172.25.254.141 parent 80 0 proxy-only # Uncomment and adjust the following to add a disk cache directory #开启缓存 cache_dir ufs /var/spool/squid 100 16 256重启服务
systemctl restart squid编辑/etc/hosts
172.25.254.241 www.octopus.com配置代理 访问结果
服务器端1(172.25.254.141) 安装apache服务,启动,同时设置默认发布文件内容为22222222222222
yum install httpd -y echo "22222222222222" >/var/www/html/index.html启动服务
systemctl start httpd测试结果 服务器端2(172.25.254.41) 安装apache服务,启动,同时设置默认发布文件内容为11111111111111
yum install httpd -y echo "111111111111111" >/var/www/html/index.html启动服务
systemctl start httpd测试结果 squid端(172.25.24.241) 配置文件
参数 weight=2 权重参数 cache_peer 172.25.254.141 parent 80 0 proxy-only no-query round-robin originserver name=web1 cache_peer 172.25.254.41 parent 80 0 proxy-only no-query round-robin originserver name=web2 weight=2 cache_peer_domain web1 web2 www.octopus.com测试机 配置/etc/hosts
172.25.254.241 www.octopus.com测试结果
