Skip to content

Instantly share code, notes, and snippets.

@hvelarde
Created December 18, 2017 21:25
Show Gist options
  • Save hvelarde/df595cb92e1928bdfaa8b046d104939f to your computer and use it in GitHub Desktop.
Save hvelarde/df595cb92e1928bdfaa8b046d104939f to your computer and use it in GitHub Desktop.
Varnish configuration to be used with HAProxy backends
vcl 4.0;
import directors;
# probe definition for health checks
probe healthcheck {
.interval = 2s;
.url = "/haproxy?monitor";
.timeout = 1s;
.threshold = 3;
.window = 5;
}
# backend definitions for HAProxy load balancers
backend default {
.host = "127.0.0.1";
.port = "8080";
.probe = healthcheck;
.first_byte_timeout = 2m;
}
backend backup {
.host = "SRV_BACKUP";
.port = "8080";
.probe = healthcheck;
.first_byte_timeout = 2m;
}
sub vcl_init {
new haproxy = directors.fallback();
haproxy.add_backend(default);
haproxy.add_backend(backup);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment