代理服务器squid,varnish

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 实现此案例需要按照如下步骤进行。

  • 步骤一:构建web服务器

  • 1)使用yum安装web软件包


[root@web ~]# yum  -y  install  httpd
.. ..
[root@web ~]# rpm  -q  httpd
httpd-2.4.6-40.el7.x86_64
  • 2)启用httpd服务,并设为开机自动运行
[root@web ~]# systemctl start httpd  ;  systemctl enable httpd
  • httpd服务默认通过TCP 80端口监听客户端请求:
[root@web ~]# netstat  -anptu  |  grep httpd
tcp        0        0        :::80        :::*        LISTEN        2813/httpd
  • 3)为Web访问建立测试文件

在网站根目录/var/www/html下创建一个名为index.html的首页文件:

[root@web ~]# cat /var/www/html/index.html 
<html>
<title>Welcome</title>
<body>
<h1>www.tarena.com</h1>
</body>
</html>

步骤二:部署Squid代理服务器

1)使用yum安装squid软件包:

[root@svr5 ~]# yum  -y  install  squid
.. ..
[root@svr5 ~]# rpm  -q  squid
squid-3.3.8-26.el7.x86_64

2)修改/etc/squid/squid.conf配置文件:

[root@svr5 ~]# vim /etc/squid/squid.conf
.. ..
http_port 80 vhost                            #置反向代理
visible_hostname svr5.tarena.com                #置主机名
cache_peer  192.168.2.100  parent 80   0  originserver   #/定义后端真实服务器信息
cache_dir ufs /var/spool/squid 200 16 128       #/硬盘缓存,缓存容量为200M
http_access allow all                            #/允许本机所有主机使用代理服务器

在这里插入图片描述

3)启动squid服务,并设置为开机启动:

[root@svr5 ~]# systemctl start squid; systemctl enable squid

4)squid服务通过TCP 80端口监听客户端请求:

[root@svr5 ~]# netstat  -anptu  |  grep 80
tcp        0        0        :::80        :::*        LISTEN        3213/(squid)

步骤三:客户端测试

通过/etc/hosts文件,配置域名解析,将域名解析为Squid服务器IP地址

[root@client ~]# cat /etc/hosts
.. ..
192.168.4.5    www.tarena.com

2)客户端开启浏览器,分别访问两个不同的域名站点

[root@client ~]# firefox http://www.tare

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值