本篇内容主要讲解“varnish怎么配置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“varnish怎么配置”吧!server1:172.25.254.20 varnishserver2:172.25.254.21 http主机:172.25.254.44Varnish是一款高性能的开源HTTP加速器在server1上:#yum install varnish-3.0.5-1.el6.x86_64.rpm varnish-libs-3.0.5-1.el6.x86_64.rpm -y# vim /etc/varnish/default.vclbackend web1 {.host = “127.0.0.1”;.port = “8080”;} #定义本机端口sub vcl_deliver {if (obj.hits > 0) {set resp.http.X-Cache = “HIT from westos cache”;}else {set resp.http.X-Cache = “MISS from westos cache”;}return (deliver);} #定义是否命中# yum install httpd -y# cd /var/www/html# echo server20.example.com > index.html# vim /etc/httpd/conf/httpd.conf# Listen 12.34.56.78:80Listen 8080 #修改http端口,防止和varnish端口冲突# /etc/init.d/httpd start# netstat -antlp #查看http 8080 端口是否开启# vim /etc/sysconfig/varnishVARNISH_LISTEN_PORT=80 # varnish端口# /etc/init.d/varnish start[root@server20 html]# iptables -L Chain INPUT (policy ACCEPT)target prot opt source destination Chain FORWA免费云主机域名RD (policy ACCEPT)target prot opt source destination Chain OUTPUT (policy ACCEPT)target prot opt source destination #查看本机火墙是否关闭[root@foundation44 Desktop]# curl -I 172.25.254.20HTTP/1.1 404 westos cacheServer: VarnishContent-Type: text/html; charset=utf-8Retry-After: 5Content-Length: 398Accept-Ranges: bytesDate: Wed, 29 Jun 2016 10:11:45 GMTX-Varnish: 1112141971Age: 0Via: 1.1 varnishConnection: closeX-Cache: MISS from westos cache #此时未命中,说明还没有缓存[root@foundation44 Desktop]# curl -I 172.25.254.20HTTP/1.1 404 westos cachServer: VarnishContent-Type: text/html; charset=utf-8Retry-After: 5Content-Length: 398Accept-Ranges: bytesDate: Wed, 29 Jun 2016 10:15:02 GMTX-Varnish: 1112141972Age: 0Via: 1.1 varnishConnection: closeX-Cache: HIT from westos cache #此时命中,说明已经有缓存# vim /etc/varnish/default.vclbackend web2 {.host = “172.25.254.21”;.port = “80”;}director lb random { #把多个后端聚合在一起{ .backend = web1;.weight = 1;}{ .backend = web2;.weight = 2;}}sub vcl_recv {if (req.http.host ~ “^(www.)?westos.org”) {set req.http.host = “www.westos.org”;set req.backend = lb;return(pass); #为了方便,所以定义不缓存} elsif (req.http.host ~ “^bbs.westos.org”) {set req.backend = web2;} else {error 404 “westos cache”;}} #如果访问其他会报错 404# /etc/init.d/varnish reload在server2上进行的操作yum install httpd -y# cd /var/www/html# echo server21.example.com > index.html# /etc/init.d/httpd start# vim /etc/httpd/conf/httpd.confNameVirtualHost *:80
这篇“linux中top命令显示不免费云主机域名全怎么解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“linux中top命令显示不全怎么解决”…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。