squid缓存服务器————反向代理

news/2024/7/23 8:19:58 标签: squid, 缓存服务器, 反向代理

如果 Squid 反向代理服务器中缓存了该请求的资源,则将该请求的资源直接返回给客户端,
否则反向代理服务器将向后台的 WEB 服务器请求资源,然后将请求的应答返回给客户端,
同时也将该应答缓存在本地,供下一个请求者使用

先给网页做区分

[root@web httpd]# cd /var/www/html/
[root@web html]# ls
[root@web html]# vim index.html
<h1>this is test1 web</h1>

在这里插入图片描述

在前面实验的基础上,新开一台web2服务器:192.168.247.161

[root@localhost ~]# hostnamectl set-hostname web2
[root@localhost ~]# su
[root@web2 ~]# 
[root@web2 ~]# systemctl stop firewalld
[root@web2 ~]# setenforce 0
[root@web2 ~]# yum install httpd -y
[root@web2 ~]# cd /var/www/html/
[root@web2 html]# vim index.html
<h1>this is test2 web2</h1>
[root@web2 html]# systemctl start httpd
[root@web2 html]# netstat -natp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      17713/httpd    
[root@web2 html]# route add -net 192.168.10.0/24 gw 192.168.247.206

切换到squid服务器192.168.247.206进行反向代理配置

[root@squid sarg]# vim /etc/squid.conf
# Squid normally listens to port 3128
http_port 192.168.247.206:80 accel vhost vport		//修改
//下面为增加
cache_peer 192.168.247.160 parent 80 0 no-query orginserver round-robinmax_conn=30 weight=1 name=web1
cache_peer 192.168.247.161 parent 80 0 no-query orginserver round-robin max_conn=30 weight=1 name=web2
cache_peer_domain web1 web2 www.yun.com
[root@squid sarg]# netstat -natp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      63454/httpd   
[root@squid sarg]# systemctl stop httpd             
[root@squid sarg]# netstat -natp | grep 80
[root@squid sarg]# service squid restart
正在关闭 squid...
正在启动 squid...
[root@squid sarg]# netstat -natp | grep 80
tcp        0      0 192.168.247.206:80      0.0.0.0:*               LISTEN      21051/(squid-1)     
[root@squid sarg]# 

关闭squid的防火墙

[root@squid sarg]# systemctl stop firewalld
[root@squid sarg]# setenforce 0

在这里插入图片描述

修改win10客户机hosts文件,使用administer
在这里插入图片描述
在这里插入图片描述

然后访问squid
在这里插入图片描述
在这里插入图片描述


http://www.niftyadmin.cn/n/1397515.html

相关文章

理论+实操:NoSQL之redis概述+部署+演示基本操作

NoSQL之Redis配置与优化 文章目录一&#xff1a;关系型数据库与非关系型数据库1.1 关系型数据库1.2 非关系型数据库1.3 非关系型数据库产生背景二&#xff1a;Redis简介三&#xff1a;redis 的优点四&#xff1a;部署redis安装编译工具&#xff0c;解压redis&#xff0c;make安…

理论+实操:NoSQL之redis配置参数+持久化详解

一&#xff1a;参数配置 [rootlocalhost redis]# vim /etc/redis/6379.conf 219 save 900 1 #900秒进行一次写操作&#xff0c;也就是保存一次220 save 300 10 #执行10次写操作&#xff0c;300秒一次221 save 60 10000 #执行10000次写操作&#xff0c;60秒一次242 rdbcompres…

实验:haproxy搭建nginx配合nginx群集实现高并发访问

三台服务器&#xff0c;一台做代理服务器&#xff0c;两台做web [rootlamp ~]# hostnamectl set-hostname haproxy [rootlamp ~]# su[rootnginx ~]# hostnamectl set-hostname nginx1 [rootnginx ~]# su [rootnginx1 ~]# [rootlocalhost ~]# hostnamectl set-hostname nginx2 …

cobbler自动装机

挂载共享目录&#xff0c;安装epel源环境 [rootnginx ~]# mkdir /abc [rootnginx ~]# mount.cifs //192.168.254.10/linuxs /abc Password for root//192.168.254.10/linuxs: [rootnginx ~]# rpm -ivh /abc/epel-release-latest-7.noarch.rpm 警告&#xff1a;/abc/epel-re…

BGP-ISIS实验

&#xff08;控制层面&#xff09;ISIS 主要功能跑底层框架路由网段&#xff1a;直连、环回地址 &#xff08;数据层面&#xff09;IBGP 直接宣告的方式&#xff0c;将业务网段发布 业务网段不在ISIS里面跑 BARS/SR中&#xff0c;它是有好多条业务网段&#xff0c;上万条 如…

理论+实操华为防火墙

华为防火墙 文章目录一&#xff1a;华为防火墙产品介绍二&#xff1a;防火墙的工作原理2.1 防火墙的工作模式2.2 华为防火墙安全区域划分2.3 防火墙Inbound和Outbound2.4 状态化信息2.5 安全策略三&#xff1a;设备管理方式3.1 AAA&#xff08;Authentication Authorization Ac…

理论+实操:防火墙NAT策略

文章目录一&#xff1a;NAT概述1.1 NAT分类1.1.1 NAT No-PAT1.1.2 NAPT&#xff08;Network Address and Port Translation&#xff0c;网络地址和端口转换&#xff09;1.1.3 出接口地址 &#xff08;Easy-IP&#xff09;1.1.4 NAT Server1.1.5 Smart NAT &#xff08;智能转换…

理论+实操:防火墙双机热备

文章目录一&#xff1a;双机热备的工作原理1.1 双机热备概述1.2 VRRP&#xff08;虚拟路由冗余协议Virtual Router Redundancy Protocol&#xff09;1.3 VGMP二&#xff1a;双机热备配置2.1 双击热备的备份方式2.2 开启双机热备功能2.3 配置自动备份模式2.4 配置手工批量备份模…