首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Linux频道
Google
首页 入门 Linux编程 系统管理 网络管理 Linux认证 Unix/BSD Linux数据库 Linux集群 Linux手册 Linux下载 Ubuntu 论坛 专题 RSS
您现在的位置: 中国IT实验室 >> Linux >> 网络管理 >> Linux服务器 >> 正文

搭建性能比Squid高很多的Varnish服务器

4.编写vcl:

我的vcl如下:

backend default {

set backend.host = "127.0.0.1";

set backend.port = "http";

}

#我用的是一台机器做测试,使用的backend用的是127.0.0.1:80.如果varnish机器和后台的机器分开的。

写上对应的机器的ip或hostname就可以了。

sub vcl_recv {

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

pipe;

}

if (req.http.Expect) {

pipe;

}

if (req.http.Authenticate || req.http.Cookie) {

pass;

}

if (req.request == "GET" && req.url ~ "\.(gif|jpg|swf|css|js)$") {

lookup;

}

lookup;

}

sub vcl_pipe {

pipe;

}

sub vcl_pass {

pass;

}

sub vcl_hash {

hash;

}

sub vcl_hit {

if (!obj.cacheable) {

pass;

}

deliver;

}

sub vcl_timeout {

discard;

}

sub vcl_discard {

discard;

}

如果是多个站点在不同的originserver时,可以使用下面配置:

backend www {

set backend.host = "www.jackbillow.com";

set backend.port = "80";

}

backend images {

set backend.host = "images.jackbillow.com";

set backend.port = "80";

}

sub vcl_recv {

if (req.http.host ~ "^(www.)?jackbillow.com$") {

set req.http.host = "www.jackbillow.com";

set req.backend = www;

} elsif (req.http.host ~ "^images.jackbillow.com$") {

set req.backend = images;

} else {

error 404 "Unknown virtual host";

}

5.启动varnish:

/usr/local/varnish/sbin/start.sh

Mon Sep 3 03:13:19 UTC 2007

file /cache/varnish/V/varnish.tEKXXx (unlinked) size 1073741824 bytes (262144 fs-blocks, 262144 pages)

Using old SHMFILE

ps waux | grep varnish

root 16254 0.0 0.0 11200 708 ? Ss 10:43 0:00 /usr/local/varnish/sbin/varnishd -a 10.0.0.129:80 -s /varnish/V,1024m

-f /usr/local/varnish/sbin/vg.vcl.default -p thread_pool_max 1500 -p thread_pools 5 -p listen_depth 512 -p client_http11 on

nobody 16255 0.0 0.1 1152552 1808 ? Sl 10:43 0:00 /usr/local/varnish/sbin/varnishd -a 10.0.0.129:80 -s

file,/cache/varnish/V,1024m -f /usr/local/varnish/sbin/vg.vcl.default -p thread_pool_max 1500 -p thread_pools 5 -p

listen_depth 512 -p client_http11 on

看到上面信息说明varnish正确启动,恭喜你,你已经配置成功了。

上一页  [1] [2] 

【责编:Yoyo】
中国IT教育
相关产品和培训
文章评论
 友情推荐链接
 专题推荐

 ·防范Linux病毒 打造没有病毒的乐土…
 ·Linux Shell编程实用指南…
 ·Linux日志分析与管理
 ·揭密Linux内存管理
 ·邮件服务Sendmail应用配置
 ·Linux 安全管理…
 ·Linux 下DNS服务器架设攻略…
 ·Linux 下的路由的配置与应用…
 ·专题:Apache实用手册
 ·全面剖析Linux文件系统
 今日更新
 认证培训
 频道精选
 Windows频道导航