一 缓存代理概述
1.1 Web代理的工作机制
● 缓存网页对象,减少重复请求
1.2 代理的基本类型
●传统代理:适用于Internet,需明确指定服务端
●透明代理:客户机不需要指定代理服务器的地址和端口,而是通过默认路由,防火墙策略将Web访问重定向给代理服务器处理
1.3 使用代理的好处
●提高Web访问速度
●隐藏客户机的真实IP地址
二 Squid安装及运行
2.1 编译安装Squid 3.4.6
2.2 Squid配置文件调整
2.3 Squid初始化
2.4 Squid启动
三 传统代理
3.1 实验环境
主机 | 系统 | IP地址 | 网关 |
---|---|---|---|
Squid代理服务器 | centos7.4 | 20.0.0.101 | 20.0.0.1 192.168.10.1 |
Web服务器 | centos7.4 | 20.0.0.102 | 20.0.0.1 |
客户机 | windows10 | 192.168.1.100 | 192.168.1.1 |
3.2 搭建传统代理步骤
##squid服务器##
1. 设置名称
[root@localhost ~]# hostnamectl set-hostname squid
[root@localhost ~]# hostnamectl set-hostname web
2. 安装Squid服务
1. 安装squid
[root@squid ~]# cd /opt/
[root@squid opt]# ll
总用量 4472
drwxr-xr-x. 2 root root 6 3月 26 2015 rh
-rw-r--r-- 1 root root 4577313 10月 30 10:44 squid-3.4.6.tar.gz
[root@squid opt]# tar zxvf squid-3.4.6.tar.gz
[root@squid opt]# cd squid-3.4.6/
[root@squid squid-3.4.6]# ./configure --prefix=/usr/local/squid \ ##安装路径
> --sysconfdir=/etc \ ##配置文件的目录
> --enable-arp-acl \ ##启用acl访问控制列表
> --enable-linux-netfilter \ ##内核过滤
> --enable-linux-tproxy \ ##支持透明代理模式
> --enable-async-io=100 \ ##对io的优化
> --enable-err-language="Simplify Chinese" \ ##报错提示是简体中文
> --enable-underscore \ ##在URL中支持下划线
> --enable-poll \ ##管理多个描述符功能的提升
> --enable-gnuregex ##支持正则表达式
[root@squid squid-3.4.6]# make -j4
[root@squid squid-3.4.6]# make install
3. 建立软链接,添加用户,授权
[root@squid squid-3.4.6]# ln -s /usr/local/squid/sbin/* /usr/local/sbin/
[root@squid squid-3.4.6]# useradd -M -s /sbin/nologin squid
[root@squid squid-3.4.6]# chown -R squid:squid /usr/local/squid/var/
4. 修改配置文件
[root@squid squid-3.4.6]# vim /etc/squid.conf
55 # And finally deny all other access to this proxy
56 http_access allow all ##添加
57 #http_access deny all
59 # Squid normally listens to port 3128
60 http_port 3128
61 cache_effective_user squid ##添加
62 cache_effective_group squid ##添加
5. 检查语法
[root@squid squid-3.4.6]# squid -k parse ##检查配置文件语法
[root@squid squid-3.4.6]# squid -z ##初始化缓存目录
[root@squid squid-3.4.6]# squid ##启动服务
[root@squid squid-3.4.6]# netstat -anpt | grep 3128
tcp6 0 0 :::3128 :::* LISTEN 38163/(squid-1)
6. 创建脚本
[root@squid squid-3.4.6]# cd /etc/init.d/
[root@squid init.d]# vim squid
#!/bin/bash
#chkconfig: 2345 90 25
PID="/usr/local/squid/var/run/squid.pid"
CONF="/etc/squid.conf"
CMD="/usr/local/squid/sbin/squid"
case "$1" in
start)
netstat -anpt | grep squid &> /dev/null
if [ $? -eq 0 ]
then
echo "squid is running"
else
echo "正在启动 squid ..."
$CMD
fi
;;
stop)
$CMD -k kill &> /dev/null
rm -rf $PID &> /dev/null
;;
status)
[ -f $PID ] &> /dev/null
if [ $? -eq 0 ]
then
netstat -anpt | grep squid
else
echo "squid is not running"
fi
;;
restart)
$0 stop &> /dev/null
echo "正在关闭 squid ..."
$0 start &> /dev/null
echo "正在启动 squid ..."
;;
reload)
$CMD -k reconfigure
;;
check)
$CMD -k parse
;;
*)
echo "用法:$0{start|stop|status|reload|check|restart}"
;;
esac
[root@squid init.d]# chmod +x squid
[root@squid init.d]# chkconfig --add squid ##service列表中添加squid
[root@squid init.d]# chkconfig --level 35 squid on
7. 验证脚本
[root@squid init.d]# service squid stop
[root@squid init.d]# netstat -anpt | grep 3128
[root@squid init.d]# service squid start
正在启动 squid ...
[root@squid init.d]# netstat -anpt | grep 3128
tcp6 0 0 :::3128 :::* LISTEN 38485/(squid-1)
8. 修改配置文件
[root@squid init.d]# vi /etc/squid.conf
# Squid normally listens to port 3128
http_port 3128
cache_effective_user squid
cache_effective_group squid
cache_mem 64 MB ##指定缓存功能使用的内存空间大小,便于保持访问较频繁的Web对象,容量最好为4的倍数,单位MB
reply_body_max_size 10 MB ##允许用户下载的最大文件大小,以字节为单位,默认设置0表示不进行限制
maximum_object_size 4096 KB ##允许保存到缓存空间的最大对象大小,以KB为单位,超过大小限制的文件将不被缓存,而是直接转到服务端
9. 设置防火墙规则
[root@squid init.d]# iptables -F
[root@squid init.d]# iptables -t nat -F
[root@squid init.d]# iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
[root@squid init.d]# service squid reload
##服务端##
1. 安装apache服务
[root@web ~]# yum -y install httpd
[root@web ~]# systemctl start httpd.service
[root@web ~]# netstat -anpt | grep 80
tcp 0 36 20.0.0.102:22 20.0.0.1:55808 ESTABLISHED 14218/sshd: root@pt
tcp6 0 0 :::80 :::* LISTEN 53797/httpd
3.3 测试
真机浏览器访问web服务器(20.0.0.102)
1. 到web服务器查看日志
[root@web ~]# cd /var/log/httpd/
[root@web httpd]# ls
access_log error_log
[root@web httpd]# cat access_log
##发现是20.0.0.1访问的
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET / HTTP/1.1" 403 4897 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/bootstrap.min.css HTTP/1.1" 200 19341 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /images/apache_pb.gif HTTP/1.1" 200 2326 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /images/poweredby.png HTTP/1.1" 200 3956 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.woff HTTP/1.1" 404 241 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.woff HTTP/1.1" 404 239 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.ttf HTTP/1.1" 404 238 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.1 - - [30/Oct/2020:13:42:39 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
2. 浏览器设置代理服务器步骤
谷歌浏览器----设置----高级----系统------打开你的代理设置-------打开使用代理服务器------地址20.0.0.102-----端口3128
3. 重新访问web(20.0.0.102)服务器
[root@web httpd]# cat access_log
20.0.0.101 - - [30/Oct/2020:13:50:31 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.woff HTTP/1.1" 404 239 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.101 - - [30/Oct/2020:13:50:31 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.woff HTTP/1.1" 404 241 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.101 - - [30/Oct/2020:13:50:31 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.ttf HTTP/1.1" 404 238 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
20.0.0.101 - - [30/Oct/2020:13:50:31 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
发现访问IP是20.0.0101
四 透明代理
4.1 搭建透明代理步骤
##squid代理服务器##
1. squid服务器添加一张网卡
[root@squid init.d]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 20.0.0.101 netmask 255.255.255.0 broadcast 20.0.0.255
inet6 fe80::76d6:f88b:c44:8378 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:4f:f7:ea txqueuelen 1000 (Ethernet)
RX packets 14108 bytes 7043881 (6.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11155 bytes 2238642 (2.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::2a14:d84f:68c:a07c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:4f:f7:f4 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 1992 (1.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
......
[root@squid init.d]# cd /etc/sysconfig/network-scripts/
[root@squid network-scripts]# cp -p ifcfg-ens33 ifcfg-ens36
[root@squid network-scripts]# vi ifcfg-ens36
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yesvi
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens36
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.10.1
NETMASK=255.255.255.0
[root@squid network-scripts]# systemctl restart network
2. 设置路由转发
[root@squid network-scripts]# vim /etc/sysctl.conf
net.ipv4.ip_forward=1
[root@squid network-scripts]# sysctl -p
net.ipv4.ip_forward = 1
##web服务器##
1. 开启apache服务
[root@web ~]# systemctl start httpd
[root@web ~]# ping 20.0.0.1 //测试网络
PING 20.0.0.1 (20.0.0.1) 56(84) bytes of data.
64 bytes from 20.0.0.1: icmp_seq=1 ttl=128 time=0.286 ms
64 bytes from 20.0.0.1: icmp_seq=2 ttl=128 time=0.288 ms
^C
--- 20.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.286/0.287/0.288/0.001 ms
[root@web ~]# ping 192.168.10.1
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_seq=1 ttl=128 time=1.17 ms
64 bytes from 192.168.10.1: icmp_seq=2 ttl=128 time=1.05 ms
2. 设置静态路由
[root@web ~]# route add -net 192.168.10.0/24 gw 20.0.0.101
##squid服务器##
1. 修改配置文件,设置透明代理
[root@squid network-scripts]# vim /etc/squid.conf
# Squid normally listens to port 3128
http_port 192.168.10.1:3128 transparent
[root@squid network-scripts]# service squid stop
[root@squid network-scripts]# service squid start
2. 设置防火墙规则
[root@squid network-scripts]# iptables -F
[root@squid network-scripts]# iptables -t nat -F
[root@squid network-scripts]# iptables -t nat -I PREROUTING -i ens36 -s 192.168.10.0/24 -p tcp --dport 80 -j REDIRECT --to 3128
[root@squid network-scripts]# iptables -t nat -I PREROUTING -i ens36 -s 192.168.10.0/24 -p tcp --dport 443 -j REDIRECT --to 3128
[root@squid network-scripts]# iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
[root@squid network-scripts]# netstat -anpt | grep 3128
tcp 0 0 192.168.10.1:3128 0.0.0.0:* LISTEN 40714/(squid-1)
4.2 测试
1. 设置VN虚拟机window10 的IP地址为192.168.10.10,把squid ens36的IP设为网关,用浏览器访问web(20.0.0.102)
2. web服务器查看日志
[root@web httpd]# cat access_log
20.0.0.101 - - [31/Oct/2020:12:10:15 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.woff HTTP/1.1" 404 241 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36"
20.0.0.101 - - [31/Oct/2020:12:10:15 +0800] "GET /noindex/css/fonts/Bold/OpenSans-Bold.ttf HTTP/1.1" 404 238 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36"
20.0.0.101 - - [31/Oct/2020:12:10:15 +0800] "GET /noindex/css/fonts/Light/OpenSans-Light.ttf HTTP/1.1" 404 240 "http://20.0.0.102/noindex/css/open-sans.css" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36"
20.0.0.101 - - [31/Oct/2020:12:10:15 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://20.0.0.102/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36"
//发现访问地址时20.0.0.101,为squid代理服务器的地址,说明透明代理成功
五 ACL访问控制
5.1 ACL访问控制方式
5.1.1 根据源地址,目标URL,文件类型等定义列表
acl 列表名称 列表类型 列表内容 ...
5.1.2 针对已定义的acl列表进行限制y
http_access allow 或 deny 列表名称 ...
5.2 常用的ACL列表类型
●src → 源地址
●dst → 目标地址
●port → 端口
●dstdomain → 目标域
●time → 访问时间
●maxconn → 最大并发连接
●url_regex → 目标URL地址
●Urlpath_regex → 整个目标URL路径
5.3 ACL列表的应用
5.3.1 最简单的ACL控制
##禁止任何客户机使用此代理服务##
[root@squid ~]# vi /etc/squid.conf
acl all src 0.0.0.0/0.0.0.0
http_access deny all
[root@squid ~]# service squid restart
ACL综合应用
##允许多个局域网在工作时间上网
[root@squid ~]# vi /etc/squid.conf
acl all src 0.0.0.0/0.0.0.0 //允许所有源地址访问
acl MYLAN src 20.0.0.0/24 192.168.10.0/24 //允许20.0.0.0网段和192.168.10.0网段访问
acl WORKTIME time MTWHFAC 08:00-17:00 //工作时间为早上八点到晚上晚点
http_access allow MYLAN WORKTIME //同时允许上面两条规则
http_access deny all //拒绝所有访问
[root@squid ~]# service squid restart
##通过黑名单限制目标网站##
[root@squid ~]# vi /etc/squid/ipblock.list
20.0.0.102
[root@squid ~]# vi /etc/squid/dmblock.list
.qq.com
.msn.com
[root@squid squdi]# vi /etc/squid.conf
acl IPBLOCK dst "/etc/squid/ipblock.list"
acl DMBLOCK dstdomain "/etc/squid/dmblock.list"
http_access deny IPBLOCK
http_access deny DMBLOCK
[root@squid ~]# service squid restart
六 Squid日志分析工具Sarg
1. 安装Sarg
[root@squid ~]# yum -y install gd gd-devel //图像处理
[root@squid ~]# mkdir /usr/local/sarg
[root@squid ~]# cd /opt/
[root@squid opt]# tar zxvf sarg-2.3.7.tar.gz
[root@squid opt]# cd sarg-2.3.7/
[root@squid sarg-2.3.7]# ./configure --prefix=/usr/local/sarg --sysconfdir=/etc/sarg --enable-extraprotection
--enable-extraprotection //额外安全防护
[root@squid sarg-2.3.7]# make && make install
2. 修改配置文件
[root@squid sarg-2.3.7]# cd /etc/sarg/
[root@squid sarg]# vim sarg.conf
7 access_log /usr/local/squid/var/logs/access.log //指定访问日志文件
25 title "Squid User Access Reports" //网页标题
120 output_dir /var/www/html/squid-reports //报告输出目录
178 user_ip no //使用用户名显示
206 exclude_hosts /usr/local/sarg/noreport //不计入排序的站点列表文件
184 topuser_sort_field connect reverse //top排序中有连接次数,访问字节,降序排序,升序是normal
190 #user_sort_field connect reverse //用户访问记录,连接次数,访问字节按降序排序
257 overwrite_report no //同名日志是否覆盖
289 mail_utility mailq.postfix //发送邮件报告命令
434 charset UTF-8 //使用字符接
518 weekdays 0-6 //top排行的星期周期
525 hours 0-23 //top排行的时间周期
633 www_document_root /var/www/html //网页根目录
3. 创建不计入站点文件,以及软链接
[root@squid sarg]# touch /usr/local/sarg/noreport //添加不计入站点文件,添加的域名不被显示在排序中
[root@squid sarg]# ln -s /usr/local/sarg/bin/sarg /usr/local/bin/ //创建软链接
4. 运行sarg,查看日志文件
[root@squid sarg]# sarg
SARG: 纪录在文件: 758, reading: 100.00%
SARG: 成功的生成报告在 /var/www/html/squid-reports/2020Oct31-2020Nov01
[root@squid sarg]# cd /var/www/html/
[root@squid html]# ll
总用量 0
drwxr-xr-x 4 root root 65 11月 1 10:58 squid-reports
[root@squid html]# cd squid-reports/
[root@squid squid-reports]# ll
总用量 8
drwxr-xr-x 3 root root 179 11月 1 10:58 2020Oct31-2020Nov01
drwxr-xr-x 2 root root 92 11月 1 10:58 images
-rw-r--r-- 1 root root 4438 11月 1 10:58 index.html
5. 安装apache服务
[root@squid squid-reports]# yum -y install httpd
[root@squid squid-reports]# systemctl start httpd.service
- window10 浏览器访问 http://192.168.10.1/squid-reports/
8. 创建周期性计划任务
[root@squid squid-reports]# sarg -l /usr/local/squid/var/logs/access.log -o /var/www/html/squid-reports/ -z -d $(date -d "1 day ago" +%d/%m/%Y)-$(date +%d/%m/%Y)
重新访问,会发现多一条访问记录
此时,也可以创建周期性计划任务,通过脚本实现
[root@squid squid-reports]# vim /usr/local/sarg/daily.sh
#!/bin/bash
TODAY=$(date +%d/%m/%Y)
YESTERDSY=$(date -d "1 day ago" +%d/%m/%Y)
/usr/local/sarg/bin/sarg -l /usr/local/squid/var/logs/access.log -o /var/www/html/sarg
-z -d $YESTERDAY-$TODAY &> /dev/null
exit 0
[root@squid squid-reports]# crontab -e
00 00 * * * /usr/local/sarg/daily.sh
七 Squid反向代理
- web1
##web1##
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ll
总用量 0
[root@localhost html]# vim index.html
<h1>this is test1 web</h1>
- web2
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim index.html
<h1>this is test2 web</h1>
3. squid
[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -t nat -F
[root@localhost ~]# iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
[root@squid squid-reports]# vim /etc/squid.conf
http_port 20.0.0.101:80 accel vhost vport
cache_peer 20.0.0.102 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web1
cache_peer 20.0.0.103 parent 80 0 no-query originserver round-robin max_conn=30 weight=1 name=web2
cache_peer_domain web1 web2 www.yun.com
- window10(客戶端)
添加映射(hosts文件)
20.0.0.101 www.yun.com
浏览器启动代理服务
地址:20.0.0.101 端口:80
浏览器访问 www.yun.com
发现web1和web2轮询