CentOS中文网

centos下安装varnish

CentOS中文网 https://www.centos.net.cn 2017-04-01 01:43 出处:网络 编辑:@iCMS
1,下载安装包,并修改文件名 wgethttp://sourceforge.net/projects/varnish/files/latest/download

1,下载安装包,并修改文件名

wgethttp://sourceforge.net/projects/varnish/files/latest/download

tarzxvfdownload

cdvarnish-2.1.3

2,安装相关组件pcre

yuminstallpcre

3,设置环境变量

exportPKG_CONFIG_PATH=/usr/local/lib/pkgconfig

4,配置

./configure--prefix=/usr/local/varnish--enable-dependency-trackin--enable-debugging-symbols--enable-developer-warnings

5,编译安装

make&&makeinstall

6,启动

./../../sbin/varnishd-f/usr/local/varnish/etc/varnish/varnish.vcl-sfile,/var/varnish_cache,1G-T127.0.0.1:2000-a0.0.0.0:9001


示例配置

[plain]view plaincopy

centos下安装varnish

[root@localhostvarnish]#catvarnish.vcl

backendcqserver{

.host="192.168.0.1";

.port="5007";

.connect_timeout=20s;

}

aclpurge{

"localhost";

"127.0.0.1";

"192.168.1.0"/24;

}

subvcl_recv{

if(req.request=="PURGE"){

if(!client.ip~purge){

error405"Notallowed.";

}

return(lookup);

}

if(req.http.host~"^192"){

setreq.backend=cqserver;

if(req.request!="GET"&&req.request!="HEAD"){

return(pipe);

}

else{

return(lookup);

}

}

else{

error404"caoqingCacheServer";

return(lookup);

}

}

subvcl_hit{

if(req.request=="PURGE"){

setobj.ttl=0s;

error200"Purged.";

}

}

subvcl_deliver{

if(obj.hits>0){

setresp.http.X-Cache="HIT";

}else{

setresp.http.X-Cache="MISS";

}

}

subvcl_miss{

if(req.request=="PURGE"){

error404"Notincache.";

}

}


0

精彩评论

暂无评论...
验证码 换一张
取 消