Using VCL with Fastly backends


#1

When you add backends to your service, you should be able to see those backends created in Varnish with the following syntax:

# As an IP address 199.00.000.0
backend F_199_00_000_0 {
...
...
}

# As a domain name `my.backend.com`
backend F_my_backend_com {
...
...
}

#As an auto load balance group of multiple backends
director autodirector_ random {
...
...
}

You can call these explicitly in VCL

sub vcl_recv {
# FASTLY RECV

  # set the autodirector as a default
  set req.backend = autodirector_;

  # set a specific backend based on a conditional
  if (req.url ~ "/img") {
    set req.backend =  F_my_backend_com;
  }
}