varnish(未成)
varnish是一款高性能的開源HTTP緩存加速器,據說性能比squid強很多倍
http://ignum.dl.sourceforge.net/project/varnish/varnish/1.1.1/varnish-1.1.1.tar.gz
# tar zxvf /usr/local/src/varnish-1.1.1.tar.gz
# cd /usr/local/src/varnish-1.1.1
# ./autogen.sh
# ./configure --prefix=/usr/local/varnish
# make && make install
# mkdir /varnish
# chmod 777 /varnish
編寫啓動文件:
# vi /usr/local/varnish/sbin/varnish.sh
#!/bin/sh
date -u
/usr/local/varnish/sbin/varnishd -a 192.168.1.10:80 -s file,/varnish,1024m -f /usr/local/varnish/vcl.conf -T 192.168.1.10:3500 -p thread_pool_max=1500 -p thread_pools=5 -p listen_depth=512 -p client_http11=on -p backend_http11=on
:wq
編寫VCL文件
# vi /usr/local/varnish/vcl.conf
backend yang {
set backend.host = "192.168.1.10";
set backend.port = "80";
}
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;
}
:wq
啓動varnish:
# /usr/local/varnish/sbin/varnish.sh
查看端口:
# netstat -ntpl varnishd
停止varnish:
# killall varnishd
開機自啓動:
# vi /etc/rc.local
/usr/local/varnish/sbin/varnish.sh
:wq
注:未成,原因還在研究中