Defining backend servers in VCL
Varnish has a concept of backend servers, or origin servers as we sometimes refer to them. A backend server is the server where the content originates. Varnish will connect to that server and cache its responses.
Wen need to tell Varnish where it can find the content. This is typically done in the default VCL file: /etc/varnish/default.vcl.
The backend definition looks like this:
vcl 4.1;
backend default {
.host = "www.varnish.org";
.port = "80";
}
This means we set up a backend in Varnish that fetches content from
the host www.varnish.org on port 80.
If the backend server is hosted on the same machine as Varnish, your .host and .port settings probably look like this:
vcl 4.1;
backend default {
.host = "127.0.0.1";
.port = "8080";
}
Varnish can have multiple backends defined and can even join several backends together into clusters of backends for load balancing purposes, having Varnish pick one backend based on different algorithms.