运维实战 CDN内容分发网络
常见的业务流程
Client
-> DNS
-> CDN
-> Proxy
-> Webserver
安装Varnish
yum install -y varnish-4.0.5-1.el7.x86_64.rpm varnish-libs-4.0.5-1.el7.x86_64.rpm jemalloc-3.6.0-1.el7.x86_64.rpm jemalloc-devel-3.6.0-1.el7.x86_64.rpm
curl 172.25.5.1
vim default.vcl
systemctl reload varnish.service
curl 172.25.5.1
curl -I 172.25.5.1
编辑主配置文件
##添加默认后端服务器
##Server2上有安装好的Nginx
cd /etc/varnish/
vim default.vcl
backend default {
.host = "172.25.5.2";
.port = "80";
}
##修改程序环境中的监听端口为80方便测试
vim varnish.params
VARNISH_LISTEN_PORT=80
使用宿主机进行测试
[root@Server1 varnish]# curl 172.25.5.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com