国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

varnish怎么配置

發(fā)布時(shí)間:2021-08-23 15:12 來(lái)源:億速云 閱讀:0 作者:chen 欄目: 網(wǎng)絡(luò )安全

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

server1:172.25.254.20  varnish

server2:172.25.254.21  http

主機:172.25.254.44

Varnish是一款高性能的開(kāi)源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 端口是否開(kāi)啟

   #  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    #查看本機火墻是否關(guān)閉

[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   #此時(shí)未命中,說(shuō)明還沒(méi)有緩存

[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    #此時(shí)命中,說(shuō)明已經(jīng)有緩存

   #  vim /etc/varnish/default.vcl

   backend web2 {

   .host = "172.25.254.21";

   .port = "80";

  }

   director lb random  {     #把多個(gè)后端聚合在一起

{ .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";

}

}        #如果訪(fǎng)問(wèn)其他會(huì )報錯 404

#  /etc/init.d/varnish reload

在server2上進(jìn)行的操作

 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上相關(guān)的解析,在主機上火狐訪(fǎng)問(wèn),或者用 curl   -I  www.westos.org

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系QQ:712375056 進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。

男女好痛好深好爽视频| 中文字幕AV无码一二三区电影| 亚洲VA久久久噜噜噜久久天堂| 婷婷俺也去俺也去官网| 55夜色66夜色国产精品视频| 人妻无奈被迫屈辱1-9|