本文共 2050 字,大约阅读时间需要 6 分钟。
CDN推送平台管理:简单的说就是利用web界面批量清除缓存
第一步:
首先在nodel1安装推送平台所需的软件包中httpd unizp php
yum install -y unzip php httpd
将推送平台压缩包bansys.zip解压到共享目录下,并编辑config.php文件
unzip bansys.zip -d /var/www/html
cd /var/www/htmllscd bansys/lsmv * ../cd ..lsvim config.php
array('172.25.11.11'), 'port' => '8080', ); //varnish群组定义 //对主机列表进行绑定 $VAR_CLUSTER = array( 'www.westos.org' => $var_group1, ); //varnish版本 //2.x和3.x推送命令不一样 $VAR_VERSION = "3";?>
修改httpd的端口vim /etc/httpd/conf/httpd.conf将端口改成8080systemctl start httpd
第三步:
编辑varnish的配置文件,设置访问控制
vim /etc/varnish/default.vcl
vcl 4.0;import directors from "/usr/lib64/varnish/vmods/libvmod_directors.so";# Default backend definition. Set this to point to your content server.acl meng { #设置的访问权限"127.0.0.1"; 本机的回环接口"172.25.11.0"/24; #使网段在172.25.11的ip都有权限清理反向代理服务器上的缓存}backend web1 { .host = "172.25.11.2"; .port = "80";}backend web2 { .host = "172.25.11.3"; .port = "80";}sub vcl_init { new lb = directors.round_robin(); lb.add_backend(web1); lb.add_backend(web2); }sub vcl_recv { # Happens before we check if we have this in cache already. # # Typically you clean up the request here, removing cookies you don't need, # rewriting the request, etc. if (req.http.host ~ "^(www.)?westos.org") {set req.http.host = "www.westos.org";set req.backend_hint = lb.backend();#return (pass); #会时时刻刻清除缓存,为了验证web网页是否可以清理缓存,实验效果明显,将这行注销掉} elsif (req.http.host ~ "^bbs.westos.org") {set req.backend_hint = web2;} else { return(synth(405)); }if (req.method == "BAN") {if (!client.ip ~ meng) {return (synth(405,"Not allowed.")); #如果不是允许的ip就拒绝清理}ban("req.url ~ " + req.url); #如果是允许的ip就进行清理return(purge);}}
systemctl restart varnish
第四步:在真机里测试
在浏览器输入172.25.11.11:8080,会出现以下界面
转载地址:http://dojvb.baihongyu.com/