table.lookup_backend
Available inall subroutines.
Looks up the key key
in the table id
. When the key is present, its
associated value will be returned. When the key is absent, the default
value is returned. The default
value is required.
Just as for the req.backend
variable,
both backend names and director names may be specified.
Example
backend b0 { .host = "203.0.113.0"; }backend b1 { .host = "203.0.113.1"; }backend b2 { .host = "203.0.113.2"; }
director d0 random { { .backend = b0; .weight = 1; } { .backend = b2; .weight = 1; }}
table t BACKEND { "a.example.com": b0, "b.example.com": b1, "c.example.com": d0,}
sub vcl_recv { set req.backend = table.lookup_backend(t, req.http.host, req.backend);}