Route traffic to other backends in VCL


#1

Routing traffic to other backends in VCL is easy. Your stock generated VCL in your current configuration should have several examples in vcl_recv, but heres a quick one:

sub vcl_recv {
# FASTLY RECV

  # set a backend based on if a url contains "/img" anywhere in the string
  if (req.url ~ "/img") {
    set req.backend =  F_my_backend_com;
  }
  # set a backend based on if a request header is present and is set
  #  _exactly_ to "MyValue"
  if (req.http.My-Specific-Header == "MyValue") {
    set req.backend =  F_my_other_backend_com;
  }
}