Squid配置
服务端
安装服务
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地址以及端口
利用客户机上网,验证配置结果
CDN搭建
服务端(172.25.254.141)
yum install -y httpd
systemctl start httpd
编辑主文件
echo "Hello World">/var/www/html/index.html
访问结果
代理端(172.25.254.241)
yum install squid
systemctl start squid
编写配置文件/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
测试机(172.25.254.41)
编辑/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
测试结果