Skip to content

Instantly share code, notes, and snippets.

@nbeguier
Created September 14, 2018 20:30
Show Gist options
  • Save nbeguier/9b78234c490104da58dfa781ee2b161e to your computer and use it in GitHub Desktop.
Save nbeguier/9b78234c490104da58dfa781ee2b161e to your computer and use it in GitHub Desktop.
VARNISH : Usage of libvmod-dynamic
vcl 4.0;
# Add import
import dynamic;
# Probe for backend api server
probe api_probe {
.interval = 5s;
.timeout = 1s;
.window = 5;
.threshold = 3;
.initial = 3;
}
# Define IPv4 only ACL for the module
acl ipv4_only { "0.0.0.0"/0; }
# in "vcl_init"
new api_1 = dynamic.director(
port = "80",
probe = api_probe,
ttl = 2m,
whitelist = ipv4_only
);
# in "vcl_recv"
set req.backend_hint = api_1.backend("api1.domain.com");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment