分类: LINUX
2011-03-16 16:59:45
# tar -xzvf bind-9.2.4.tar.gz
# tar -xzvf GeoIP-1.4.6.tar.gz
# cd GeoIP-1.4.6
# ./configure –prefix=/usr/local/geoip
# make
# make install
# cd ..
# patch -p0 < bind-9.2.4-geodns-patch/patch.diff //给bind9打补丁,让bind9直接支持geoip库
# cd bind-9.2.4
# CFLAGS=”-I/usr/local/geoip/include” LDFLAGS=”-L/usr/local/geoip/lib -lGeoIP” ./configure –prefix=/usr/local/bind
# make
# make install
view “us” {
// 匹配北美的客户端 US & Canada
match-clients { country_US; country_CA; };
// Provide recursive service to internal clients only.
recursion no;
zone “cdn.xianglei.com” {
type master;
file “pri/xianglei-us.db”;
};
zone “.” IN {
type hint;
file “named.ca”;
};
};
view “latin” {
// 匹配到南美国家
match-clients { country_AR; country_CL; country_BR; };
recursion no;
zone “cdn.xianglei.com” {
type master;
file “pri/xianglei-latin.db”;
};
zone “.” IN {
type hint;
file “named.ca”;
};
};
# ./configure –prefix=/usr/local/nginx –with-http_realip_module
# make
# make install
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream dynamic_node {
server 1.1.1.1:80; # 1.1.1.1 是主DNS节点的IP地址
}
server {
listen 8080;
server_name cdn.xianglei.net;
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css|mp3|swf|ico|flv)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass
proxy_store /var/www/cache$uri;
proxy_store_access user:rw group:rw all:r;
}
# tar -xzvf varnish-2.1.2.tar.gz
# ./configure –prefix=/usr/local/varnish
# make
# make install
backend default {
.host = “127.0.0.1″;
.port = “8080″;
}sub vcl_recv {
if (req.url ~ “\.(js|css|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$”) {
return (lookup);
}
}sub vcl_fetch {
if (req.url ~ “\.(js|css|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$”) {
unset obj.http.set-cookie;
}
}
本文出自 “实践检验真理” 博客,请务必保留此出处http://slaytanic.blog.51cto.com/2057708/516093