zoukankan      html  css  js  c++  java
  • linux服务之varnish

    https://www.varnish-cache.org/installation/redhat
    varnish是现在很流行的一个HTTP(80)缓存加速解决方案,
    varnish是基于内存的缓存加速.
    Varnish 4.0:
        rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
        yum install varnish

    Installing Varnish Cache is as simple as enabling our package repository and installing the packages. Varnish Cache 4.0 is supported on EL6, and Varnish Cache 3.0 is supported on EL5 and EL6.

    sub vcl_recv {
    if (req.request == "PURGE")
    {if (!client.ip ~ purge)
    {error 405 "Not allowed.";}
    return(lookup);
    }
    if (req.http.host ~ "^google.com") {                  #web1对应的域名
    set req.backend = web1;}
    elseif (req.http.host ~ "^(www)|(my).baidu.com") {        #web2对应的域名
    set req.backend = web2;}
    else {
    error 404 "Caesar's cache-server ! QQ: 189717888"; #如果域名不在以上范围的出错提示
    #set req.backend = web1;
    }
    if (req.request != "GET" && req.request != "HEAD") {
    return(pipe);
    }
    elseif (req.url ~ ".(php|cgi)($|?)")                #动态页面直接通过,不缓存
    {
    return(pass);
    }
    return(lookup);
    }
    sub vcl_hit {
    if (req.request == "PURGE") {
    set obj.ttl = 0s;
    error 200 "Purged.";
    }
    }
    sub vcl_miss {
    if (req.request == "PURGE") {
    error 404 "Not in cache.";
    }
    }

  • 相关阅读:
    HTML特效代码大全
    PHP网站加网站访问量统计
    定时显示隐藏
    加入收藏 设为首页
    IP和归属地
    手机站的拨打电话和发短信
    Shell运算
    Shell命令替换与变量替换
    $* 和 $@ 的区别
    Shell特殊变量列表
  • 原文地址:https://www.cnblogs.com/createyuan/p/3816032.html
Copyright © 2011-2022 走看看