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);
}