I'm using varnish to load balance between two servers and I have set up a director and two backends which are doing this successfully.
My problem is my two backends are running nginx
on port 80
listing for my.domain.com
. Nginx then reroutes my request to a process listening on port 3000
. My process has a route called /healthcheck
which I would like to use for the varnish backend probe.
This is currently what my .vcl
file looks like:
backend b0 {
.host = "53.243.15.198";
.probe = {
.url = "/healthcheck";
.timeout = 34 ms;
.interval = 1s;
.window = 10;
.threshold = 8;
}
}
So if I navigate to my.domain.com/healthcheck
I get a 200 OK
but when varnish initiates the request nginx
doesn't pick it up since it's no longer originating from my.domain.com
.
I've tried this based on this documentation but it Doesn't work:
backend b0 {
.host = "53.243.15.198";
.probe = {
.request =
"GET /healthcheck HTTP/1.1"
"Host: 53.243.15.198:3000"
"Connection: close";
.timeout = 34 ms;
.interval = 1s;
.window = 10;
.threshold = 8;
}
}
How can I health check my instances without running into this problem? Or in other words is there some way to query a different port then the main one for the backend?
You still need to send healthcheck to nginx
. However, your probes must have a HTTP Host my.domain.com
:
backend b0 {
.host = "53.243.15.198";
.host_header = "my.domain.com";
.probe = {
.url = "/healthcheck";
.timeout = 34 ms;
.interval = 1s;
.window = 10;
.threshold = 8;
}
}