情境
example.com/a/test.html -> a.example.com/test.html
example.com/b/test.html -> b.example.com/test.html

# vi /etc/varnish/default.vcl
 

vcl 4.0;

import directors;
import std;

[.... 中間略 ....]

sub vcl_recv {
    if (req.http.host ~ "example.com") {
        if (req.url ~ "^/a/") {
            set req.url = regsub(req.url, "^/a","");
            set req.http.host = "a.example.com";
            set req.backend_hint = a.backend();
        } else if (req.url ~ "^/b/") {
            set req.url = regsub(req.url, "^/b","");
            set req.http.host = "b.example.com";
            set req.backend_hint = b.backend();
        }
    }
}

undefined

arrow
arrow
    文章標籤
    varnish cache
    全站熱搜

    helloworld 發表在 痞客邦 留言(0) 人氣()