Loading...


Related Products


Date Published: February 5, 2025

Simplified VCL for Varnish

Issue

I would like to set up a local environment with Varnish to closely resemble what I have hosted. 

Resolution

If you're using Varnish, the following VCL file has helped some customers who are setting up local environments that closely resemble Acquia Cloud systems.

backend default {
   .host = "127.0.0.1";
   .port = "8080";
   .connect_timeout = 2s;
}
 
sub vcl_recv {
  if (req.http.X-Forwarded-For) {
    set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
  } else {
    set req.http.X-Forwarded-For = client.ip;
  }
  if (req.request != "GET" && req.request != "HEAD") {
    return(pass);
  }
  if(req.url ~ "^/cron.php") {
    return(pass);
  }
  if(req.url ~ "^/xmlrpc.php") {
    return(pass);
  }
  if (req.http.Authorization) {
    return(pass);
  }
  if(req.http.cookie ~ "(^|;\s*)(SESS=)") {
    return(pass);
  }
  return(lookup);
}

This is a basic example. If you have other needs or tests you want to perform, we suggest that you visit the VCL examples page, which includes several real-world examples of VCL that you can use for reference. Note that the session cookie can start with SSESS and SESS.

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation