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

  • 相关阅读:
    运维岗春招--part2
    python 题库|刷题
    leetcode刷题
    运维面经汇总
    python自动化运维阅读笔记
    Python编程汇总
    old_boy 运维学习-第一期
    团队博客作业-Week3
    个人对final发布产品的排名
    各组对final发布产品的排名
  • 原文地址:https://www.cnblogs.com/createyuan/p/3816032.html
Copyright © 2011-2022 走看看