理论+实验 详解Squid部署--传统代理--透明代理--日志分析--反向代理
目录
- 一 缓存代理概述
- 1.1 Web代理的工作机制
- 1.2 代理的基本类型
- 1.3 使用代理的好处
- 二 Squid安装及运行
- 2.1 编译安装Squid 3.4.6
- 2.2 Squid配置文件调整
- 2.3 Squid初始化
- 2.4 Squid启动
- 三 传统代理
- 3.1 实验环境
- 3.2 搭建传统代理步骤
- 3.3 测试
- 四 透明代理
- 4.1 搭建透明代理步骤
- 4.2 测试
- 五 ACL访问控制
- 5.1 ACL访问控制方式
- 5.1.1 根据源地址,目标URL,文件类型等定义列表
- 5.1.2 针对已定义的acl列表进行限制y
- 5.2 常用的ACL列表类型
- 5.3 ACL列表的应用
- 5.3.1 最简单的ACL控制
- ACL综合应用
- 六 Squid日志分析工具Sarg
- 七 Squid反向代理
一 缓存代理概述
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 web2. 安装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 install3. 建立软链接,添加用户,授权
[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.conf55 # And finally deny all other access to this proxy56 http_access allow all ##添加57 #http_access deny all59 # Squid normally listens to port 312860 http_port 312861 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" instart)netstat -anpt | grep squid &> /dev/nullif [ $? -eq 0 ]thenecho "squid is running"elseecho "正在启动 squid ..."$CMDfi;;stop)$CMD -k kill &> /dev/nullrm -rf $PID &> /dev/null;;status)[ -f $PID ] &> /dev/nullif [ $? -eq 0 ]thennetstat -anpt | grep squidelseecho "squid is not running"fi;;restart)$0 stop &> /dev/nullecho "正在关闭 squid ..."$0 start &> /dev/nullecho "正在启动 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 on7. 验证脚本[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-----端口31283. 重新访问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 1500inet 20.0.0.101 netmask 255.255.255.0 broadcast 20.0.0.255inet6 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 0TX packets 11155 bytes 2238642 (2.1 MiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet6 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 0TX 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 network2. 设置路由转发
[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 ms2. 设置静态路由
[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 start2. 设置防火墙规则
[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.confacl all src 0.0.0.0/0.0.0.0http_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 install2. 修改配置文件
[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.html5. 安装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轮询
理论+实验 详解Squid部署--传统代理--透明代理--日志分析--反向代理相关推荐
- 缓存加速-----Squid-访问控制列表日志分析反向代理
文章目录 一: ACL访问控制 1.1: ACL访问控制概述 1.2: ACL访问控制实验 二: Squid日志分析 三: 反向代理 3.1: 反向代理详解 3.2: 实验分析以及结构图 3.3: 具 ...
- squid缓存服务器 ACL访问控制 传统代理 透明代理 squid日志分析 反向代理
缓存代理概述 Squid提供了强大的代理控制机制,通过合理的设置ACL,并进行限制,可以针对源地址.目标地址.访问的URL路径.访问的时间等条件进行过滤. 作为应用层的代理服务器软件,Sqiod主要提 ...
- 理论+实验 详解MySQL全量,增量备份与恢复
目录 一 数据库备份的分类 1.1造成数据丢失的原因 1.2 数据库备份的分类 1.3 常见的备份方法 1.3.1 物理备份 1.3.2 专用备份工具mydump或者mysqlhotcopy 1.3. ...
- 理论+实验 详解MySQL高级SQL语句
目录 一 MySQL进阶查询 1.1 常用查询介绍 1.1.1 按关键字查询 1.1.2 对结果进行分组 1.1.3 限制结果条目 1.1.4 设置别名 1.1.5 通配符 1.1.6 子查询 1.2 ...
- 实验详解——Cobbler自动部署最小化安装
实验详解--Cobbler自动部署最小化安装 一.实验:自动部署 二.Cobbler自动装机服务搭建步骤 1.导入epel源并加载在线安装源 2.安装Cobbler以及其相关服务软件包 3.修改cob ...
- 详解SCCM2007部署
详解 SCCM2007 部署 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-c ...
- 【机器学习基本理论】详解最大似然估计(MLE)、最大后验概率估计(MAP),以及贝叶斯公式的理解
[机器学习基本理论]详解最大似然估计(MLE).最大后验概率估计(MAP),以及贝叶斯公式的理解 https://mp.weixin.qq.com/s/6H0gmMWvTExySMraroLVlQ 最 ...
- 【机器学习基本理论】详解最大后验概率估计(MAP)的理解
[机器学习基本理论]详解最大后验概率估计(MAP)的理解 https://mp.weixin.qq.com/s/dQxN46wEbFrpvV369uOHdA 最大似然估计(Maximum likeli ...
- LVS原理详解及部署之五:LVS+keepalived实现负载均衡高可用
本文我们主要讲解的是LVS通过keepalived来实现负载均衡和高可用,而不是我们第三篇文章介绍的通过手动的方式来进行配置.通过脚本的方式来显示RS节点的健康检查和LVS的故障切换.此文会通过一个实 ...
最新文章
- 20多岁大专生吐槽:面试39岁同济大学毕业的测试专家,对方却连简单编程题都不会!...
- 脑机接口,风口还是入口?
- 事务的传播行为和隔离级别[transaction behavior and isolated level]
- Server2003PDC迁移到Server2008R2BDC
- RabbitMQ持久化交换机队列
- 尚学堂Spring视频教程(二):Spring控制反转
- matplotlib实践过程总结
- 线段树动态开点区间加区间求和
- 使用Spring AOP进行面向方面的编程
- C# 10 的五大新功能
- 关于iOS7之后状态栏修改总结
- win11环境变量如何打开 Windows11查看环境变量的步骤方法
- 1、javascript的继承function
- php smarty安装,smarty安装(PHP)
- vi 和 vim 编辑器的使用
- 常见的引脚功能介绍(基于ADSP-SC589芯片)
- 使用Labelimg打标签
- lol服务器什么时候维护,lol等短时间维护是什么?lol11月23日服务器维护详情介绍...
- 初学者如何查阅自然语言处理领域学术资料(转)
- Maven >3.2