varnish
1. varnish的安装(rhel8中)
# yum install -y varnish.x86_64
# systemctl start varnish
# vim /usr/lib/systemd/system/varnish.service
# rpm -qc varnish
测试
‘’
2.逆向代理
# vim /etc/varnish/default.vc
在servera中编写默认发布页面
# vim /var/www/html/index.html
测试:访问目的主机时,看到的是servera的默认发布页面
# ps ax | grep varnish
3.缓存
# vim /etc/varnish/default.vcl
测试:在serverb主机中
# curl -I 192.168.1.40
清除缓存
# varnishadm ban req.url "~" / 清理所有
# varnishadm ban req.url "~" /index.html 清除页面缓存
再次访问
4.负载均衡
导入调度器模块
# vim /etc/varnish/default.vcl
# systemctl restart varnish
测试:
轮询的去访问server1和server2
使用php页面清除缓存
# yum install -y php
# vim /etc/httpd/conf/httpd.conf 修改端口为8080
# systemctl restart httpd
设置推送列表
测试:在server1主机中访问www.westos.org
# curl -I www.westos.org
第一次访问
第二次
# curl -I www.westos.org
第三次
# curl -I www.westos.org
推送页面
没有推送前
推送之后