91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

varnish怎么配置

發布時間:2021-08-12 10:47:05 來源:億速云 閱讀:190 作者:chen 欄目:網絡安全

本篇內容主要講解“varnish怎么配置”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“varnish怎么配置”吧!

server1:172.25.254.20  varnish

server2:172.25.254.21  http

主機:172.25.254.44

Varnish是一款高性能的開源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.vcl

backend 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:80

Listen 8080     #修改http端口,防止和varnish端口沖突

   #  /etc/init.d/httpd start

   #  netstat -antlp   #查看http 8080 端口是否開啟

   #  vim /etc/sysconfig/varnish

     VARNISH_LISTEN_PORT=80   # varnish端口

  #  /etc/init.d/varnish start

    [root@server20 html]# iptables -L   

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination    #查看本機火墻是否關閉

[root@foundation44 Desktop]# curl -I 172.25.254.20

HTTP/1.1 404 westos cache

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 398

Accept-Ranges: bytes

Date: Wed, 29 Jun 2016 10:11:45 GMT

X-Varnish: 1112141971

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: MISS from westos cache   #此時未命中,說明還沒有緩存

[root@foundation44 Desktop]# curl -I 172.25.254.20

HTTP/1.1 404 westos cach

Server: Varnish

Content-Type: text/html; charset=utf-8

Retry-After: 5

Content-Length: 398

Accept-Ranges: bytes

Date: Wed, 29 Jun 2016 10:15:02 GMT

X-Varnish: 1112141972

Age: 0

Via: 1.1 varnish

Connection: close

X-Cache: HIT from westos cache    #此時命中,說明已經有緩存

   #  vim /etc/varnish/default.vcl

   backend 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.conf

NameVirtualHost  *:80

<VirtualHost *:80>

        DocumentRoot /var/www/html

        ServerName www.westos.org

        serveralias westos.org

</VirtualHost>

<VirtualHost *:80>

        DocumentRoot /var/www/virtualhost/bbs

        ServerName bbs.westos.org

</VirtualHost>

   #  mkdir -p  /var/www/virtualhost/bbs

   #  cd /var/www/virtualhost/bbs/

   #  echo bbs.example.com > index.html  

   #  /etc/init.d/httpd restart

   #  vim /etc/httpd/conf/httpd.conf

   # /etc/init.d/httpd restart

然后在主機上加上 server1上和server2上相關的解析,在主機上火狐訪問,或者用 curl   -I  www.westos.org

到此,相信大家對“varnish怎么配置”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

蓬莱市| 卢氏县| 右玉县| 福泉市| 荣昌县| 方山县| 泰和县| 望城县| 淮北市| 台东县| 侯马市| 邯郸市| 张家界市| 庆元县| 长阳| 大余县| 彭泽县| 玉树县| 利川市| 延庆县| 宁远县| 太白县| 囊谦县| 沈阳市| 栖霞市| 项城市| 宝兴县| 咸阳市| 吉隆县| 双柏县| 望谟县| 东乡族自治县| 西林县| 绿春县| 永顺县| 荆门市| 孟津县| 南陵县| 土默特左旗| 宁乡县| 安义县|