Varnish 4+ configurations

How to setup healthcheck for clustered backend webservers to which the Varnish server is listening to:

 

in your vcl config file add the following:

### Varnish4+_builtin.vcl
### Custom settings for web server load balanced caching

vcl 4.0;
import directors; // <- load the vmod_directors

probe nodeprobe{
.url = “/”;
.interval = 5s;
.timeout = 1s;
.window = 5;
.threshold = 3;
.expected_response = 200;
}

backend b1 {
.host = “a.b.c.d1”;
.port = “80”;
.probe = nodeprobe;
}

backend b1 {
.host = “a.b.c.d2”;
.port = “80”;
.probe = nodeprobe;
}

## add more node configuration as needed here . . .

sub vcl_init {
new clusterweb = directors.round_robin();
clusterweb.add_backend(b1);
clusterweb.add_backend(b2);
## add more cluster members here…
}

acl purge {
}

sub vcl_recv {
set req.backend_hint = clusterweb.backend();

}
sub vcl_deliver {

}

sub vcl_backend_response {

}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: