Varnish的CDN推送管理平台搭建
1.获得平台搭建资源,解压,在此之前要安装解压工具,httpd和php,用来识别平台网页文件
yum install unzip httpd php -y
unzip bansys.zip -d /var/www/ html
.
2.将解压的文件内容移动到apache默认发布目录
cd /var/www/html/bansys/
[[email protected] bansys]# ls
class_socket.php config.php index.php purge_action.php static
[[email protected] bansys]# mv * ../
[[email protected] bansys]# ls
[[email protected] bansys]# cd ..
[[email protected] html]# ls
bansys class_socket.php config.php index.php purge_action.php static
[[email protected] html]# rm -rf bansys/
[[email protected] html]# ls
class_socket.php config.php index.php purge_action.php static
3.编辑config.php
4.修改http端口,(varnish服务已占用80端口)
vim /etc/httpd/conf/httpd.conf
Listen 8080
5.修改推送平台的配置文件
90 acl taylor {
91 “127.0.0.1”;
92 “172.25.61.0”/24;
93 }
94 backend web1 {
95 .host = “172.25.61.2”;
96 .port = “80”;
97 }
98
99 backend web2 {
100 .host = “172.25.61.3”;
101 .port = “80”;
102 }
103 director lb round-robin {
104 { .backend = web1; }
105 { .backend = web2; }
106 }
107 sub vcl_recv{
108 if (req.request == “BAN”) {
109 if (!client.ip ~ west) {
110 error 405 “Not allowed.”;
111 }
112 ban("req.url ~ " + req.url);
113 error 200 “ban added”;
114 }
115 }
116 sub vcl_recv {
117 if (req.http.host ~ “^(www.)?west.org”) {
118 set req.http.host = “www.westos.org”;
119 set req.backend = lb;
120 return (pass);
121 } elsif (req.http.host ~ “^bbs.west.org”) {
122 set req.backend = web2;
123 } else {error 404 “westos cache”;
124 }
125 }
128 sub vcl_deliver {
129 if (obj.hits >0 ){
130 set resp.http.X-Cache = “HIT from westos cache”;
131 }
132 else {
133 set resp.http.X-Cache = “MISS from westos cache”;
134 }
135 return (deliver);
136 }
5.重新加载配置
/etc/init.d/varnish reload
/etc/init/httpd start
6.测试
推送成功