<tfoot id="wg9qp"></tfoot>
    <blockquote id="wg9qp"><tbody id="wg9qp"></tbody></blockquote>
    <nobr id="wg9qp"><listing id="wg9qp"><optgroup id="wg9qp"></optgroup></listing></nobr>
    <wbr id="wg9qp"></wbr>
    <button id="wg9qp"><noscript id="wg9qp"></noscript></button>

      天堂a无码a无线孕交,日本激情久久精品人妻热,日韩人妻无码精品久久久不卡 ,国产精品无码专区,影音先锋在线资源无码,蜜臀av久久国产午夜,日本一区二区三区专线,亚洲日韩性欧美中文字幕

      Varnish配置筆記記錄

      時(shí)間:2022-10-05 23:21:22 電腦安全

      關(guān)于Varnish配置筆記記錄

        導(dǎo)語:Varnish是一個(gè)開源的反向代理軟件和HTTP加速器,與傳統(tǒng)的Squid相比,Varnish具有性能更高、速度更快、管理更方便等諸多優(yōu)點(diǎn),很多大型的運(yùn)營網(wǎng)站都開始嘗試用Varnish來替換Squid,這些都促使Varnish迅速發(fā)展起來。
       

      關(guān)于Varnish配置筆記記錄

        1、準(zhǔn)備工作及下載源碼包

        yum install -y automake autoconf libtool ncurses-devel libxslt groff pcre-devel pkgconfig

        wget http://repo.varnish-cache.org/source/varnish-3.0.3.tar.gz

        2、安裝

        tar zxf varnish-3.0.3.tar.gz

        cd varnish-3.0.3

        ./autogen.sh

        ./configure --prefix=/usr/local/varnish

        make && make install

        3、添加Varnishd進(jìn)程用戶www,用戶組www,創(chuàng)建/var/vcache目錄,使www用戶有權(quán)限可讀寫

        groupadd www

        useradd www -g www

        mkdir /home/vcache

        chown -R www:www /home/vcache

        chmod -R 750 /home/vcache

        4、編輯/etc/sysctl.conf 優(yōu)化幾個(gè)內(nèi)核參數(shù)

        net.ipv4.tcp_fin_timeout = 30

        net.ipv4.tcp_keepalive_time = 300

        net.ipv4.tcp_syncookies = 1

        net.ipv4.tcp_tw_reuse = 1

        net.ipv4.tcp_tw_recycle = 1

        net.ipv4.ip_local_port_range = 5000 65000

        運(yùn)行sysctl -p 重新按配置文件設(shè)置內(nèi)核參數(shù)

        5、啟動(dòng)Varnishd

        /usr/local/varnish/sbin/varnishd -u www -g www -f /usr/local/varnish/etc/varnish/varnish.conf -a 0.0.0.0:80 -s file,/home/vcache/varnish_cache.data,100M -w 1024,8192,10 -t 3600 -T 127.0.0.1:3500

        參數(shù)說明:

        -u 以什么用運(yùn)行

        -g 以什么組運(yùn)行

        -f varnish配置文件

        -a 綁定IP和端口

        -s varnish緩存文件位置與大小

        -w 最小,最大線程和超時(shí)時(shí)間

        -T varnish管理端口,主要用來清除緩存

        -p client_http11=on 支持http1.1協(xié)議

        -P(大P) /usr/local/varnish/var/varnish.pid 指定其進(jìn)程碼文件的位置,實(shí)現(xiàn)管理

        6、啟動(dòng)varnishncsa用來將Varnish訪問日志寫入日志文件:

        /usr/local/varnish/bin/varnishncsa -n /home/vcache -w /var/log/varnish.log &

        7、Varnish 緩存清除

        /usr/local/varnish/bin/varnishadm -T 192.168.1.180:3500 purge "req.http.host ~ www.5013.org$ && req.url ~ /static/image/tp.php"

        說明:

        192.168.1.180:3000 為被清除緩存服務(wù)器地址

        www.5013.org 為被清除的域名

        /static/image/tp.php 為被清除的url地址列表

        清除所有緩存

        /usr/local/varnish/bin/varnishadm -T 192.168.1.180:3500 url.purge *$

        清除image目錄下所有緩存

        /usr/local/varnish/bin/varnishadm -T 192.168.1.180:3500 url.purge /image/

        8、將加入啟動(dòng)項(xiàng)

        vi /etc/rc.local

        ulimit -SHn 51200

        /usr/local/varnish/sbin/varnishd -u www -g www -f /usr/local/varnish/etc/varnish/varnish.conf -a 0.0.0.0:80 -s file,/home/vcache/varnish_cache.data,100M -w 1024,8192,10 -t 3600 -T 127.0.0.1:3500

        /usr/local/varnish/bin/varnishncsa -n /home/vcache -w /var/log/varnish.log &

        9、殺掉varnishd進(jìn)程

        pkill varnishd

        10、查看varnishd命中率

        /usr/local/varnish/bin/varnishstat

        11、更新系統(tǒng)時(shí)間

        yum install -y ntp

        ntpdate time.nist.gov

        echo "00 01 * * * ntpdate time.nist.gov" 》 /etc/crontab

        附件多主機(jī)多域名varnish.conf 配置

        backend blog {

        .host = "198.56.193.190";

        .port = "80";

        }

        backend www {

        .host = "192.168.1.170";

        .port = "80";

        }

        sub vcl_recv {

        if (req.http.host ~ "^(www.)?5013.org$") {

        set req.backend = blog;

        } elsif (req.http.host ~ "^(www.)?(test1.com|test2.com)$") {

        set req.backend = www;

        } else {

        error 404 "Unknown virtual host";

        }

        }

        sub vcl_recv {

        if (req.restarts == 0) {

        if (req.http.x-forwarded-for) {

        set req.http.X-Forwarded-For =

        req.http.X-Forwarded-For + ", " + client.ip;

        } else {

        set req.http.X-Forwarded-For = client.ip;

        }

        }

        #把除了以下這些類型請求以外的訪問請求全部直接管道發(fā)送到后端的服務(wù)器

        if (req.request != "GET" &&

        req.request != "HEAD" &&

        req.request != "PUT" &&

        req.request != "POST" &&

        req.request != "TRACE" &&

        req.request != "OPTIONS" &&

        req.request != "DELETE") {

        /* Non-RFC2616 or CONNECT which is weird. */

        return (pipe);

        }

        #只有GET與HEAD方法才會(huì)使用Lookup,使用緩存。

        if (req.request != "GET" && req.request != "HEAD") {

        /* We only deal with GET and HEAD by default */

        return (pass);

        }

        # if (req.http.Authorization || req.http.Cookie) {

        # /* Not cacheable by default */

        # return (pass);

        # }

        #如果請求的是php頁面直接轉(zhuǎn)發(fā)到后端服務(wù)器

        if (req.url ~ ".(php|cgi)($|?)") {

        return (pass);

        }

        return (lookup);

        }

        sub vcl_pipe {

        return (pipe);

        }

        sub vcl_pass {

        return (pass);

        }

        sub vcl_hash {

        hash_data(req.url);

        if (req.http.host) {

        hash_data(req.http.host);

        } else {

        hash_data(server.ip);

        }

        return (hash);

        }

        sub vcl_hit {

        return (deliver);

        }

        sub vcl_miss {

        return (fetch);

        }

        sub vcl_fetch {

        if (beresp.ttl <= 0s ||

        beresp.http.Set-Cookie ||

        beresp.http.Vary == "*") {

        /*

        * Mark as "Hit-For-Pass" for the next 2 minutes

        */

        set beresp.ttl = 120 s;

        return (hit_for_pass);

        }

        if (req.url ~ ".(png|gif|jpg)$") {

        unset beresp.http.set-cookie;

        set beresp.ttl = 1h;

        }

        #設(shè)置圖片的緩存TTL為一小時(shí)

        return (deliver);

        }

        sub vcl_deliver {

        return (deliver);

        }

        sub vcl_error {

        set obj.http.Content-Type = "text/html; charset=utf-8";

        set obj.http.Retry-After = "5";

        synthetic {"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

        Error "} + obj.status + " " + obj.response + {"

        "} + obj.response + {"

        Guru Meditation:

        XID: "} + req.xid + {"

        Varnish cache server

        "};

        return (deliver);

        }

        sub vcl_init {

        return (ok);

        }

        sub vcl_fini {

        return (ok);

        }

      【Varnish配置筆記記錄】相關(guān)文章:

      托福聽力考試筆記的記錄技巧點(diǎn)撥11-27

      初中數(shù)學(xué)課堂筆記記錄有什么技巧10-13

      和弦配置的基本方法09-23

      歌曲和弦配置法09-17

      如何正確的配置網(wǎng)絡(luò)09-16

      辦公電腦配置推薦11-26

      正確的配置網(wǎng)絡(luò)的步驟11-27

      查看電腦主板配置的方法12-23

      網(wǎng)絡(luò)配置基礎(chǔ)知識(shí)10-14

      鋼琴和弦配置的基本方法08-04

      主站蜘蛛池模板: 亚洲高清有码在线观看| 久久天天丁香婷婷中文字幕| 高h纯肉无码视频在线观看| 中文字幕国产原创国产| 大香焦一区二区三区| 91免费精品国偷自产在线在线| 人妻激情偷一区二区三区| 国产亚洲欧洲人人网| 国产精品久久久久7777按摩| 免费AV片在线观看无需播放器 | 日韩AV一区二区三区| 亚洲欧美综合人成在线| 久久香蕉国产线看观看精品yw| 一本色道久久综合亚洲精品婷婷| 国产精品成人一区二区不卡| 国产国产午夜福利视频| 少妇天堂久久性| 国产在热线精品视频国产一二| 亚洲精平久| av在线播放无码线| 成人午夜福利| 日韩人妻精品| 国产成人精品永久免费视频| 欧洲免费一区二区三区视频| 国产wwww| a级亚洲片精品久久久久久久| 国产精品自拍视频免费看| 无码人妻中文字幕| 亚洲AV亚洲| 精品伊人久久久香线蕉| 国产情侣激情在线对白| 亚洲国产成人无码AV在线| 97人妻一区二区在线视频| 欧美韩中文精品有码视频在线| 亚洲精品二区在线播放| 久久av无码精品人妻糸列| 亚洲国产综合在线区尤物| 久久福利影院| 亚洲综合天堂一区二区三区| 18禁无遮挡啪啪无码网站| 亚洲va国产va天堂va久久|