私はこれを行う方法について VCL を理解しようと狂ったように試みてきましたが、それは不可能だと考え始めています。さまざまなホストにサービスを提供するバックエンド アプリ サーバーがいくつかあります。任意のホストのページをキャッシュし、キャッシュを逃したリクエストをリクエスト (「www.site.com」) に元のホスト情報を含めてアプリ サーバーに送信するには、ワニスが必要です。ただし、すべての VCL の例では、バックエンド サーバーに特定のホスト名 (「backend1」など) を使用する必要があるようです。これを回避する方法はありますか?キャッシュ ミスを IP に向けるだけで、リクエスト ホストはそのままにしておきたいと思います。
これが私が今持っているものです:
backend app1 {
.host = "192.168.1.11";
.probe = {
.url = "/heartbeat";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
backend app2 {
.host = "192.168.1.12";
.probe = {
.url = "/heartbeat";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
director pwms_t247 round-robin {
{
.backend = app1;
}
{
.backend = app2;
}
}
sub vcl_recv {
# pass on any requests that varnish should not handle
if (req.request != "HEAD" && req.request != "GET" && req.request != "BAN") {
return (pass);
}
# pass requests to the backend if they have a no-cache header or cookie
if (req.http.x-varnish-no-cache == "true" || (req.http.cookie && req.http.cookie ~ "x-varnish-no-cache=true")) {
return (pass);
}
# Lookup requests that we know should be cached
if (req.url ~ ".*") {
# Clear cookie and authorization headers, set grace time, lookup in the cache
unset req.http.Cookie;
unset req.http.Authorization;
return(lookup);
}
}
等...
これは私の最初の StackOverflow の質問です。何か重要なことを言い忘れていたら教えてください。ありがとう。