Can I use Cloudflare and Varnish together?

You may also modify vcl_recv to strip the __cfduid cookies set by Cloudflare so Varnish can cache the response. The following VCL will strip all cookies starting with two underscores or including 'has_js', such as Cloudflare and Google Analytics cookies:

    sub vcl_recv {
      # Remove has_js and Cloudflare/Google Analytics __* cookies.
      set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
      # Remove a ";" prefix, if present.
      set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");

Also see: Cloudflare and Varnish 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.