FIXED: Varnish Caching Proxy Expected an action, ‘if’, ‘{‘ or ‘}’

  • Post by Mike Dixson
  • Feb 10, 2017
post-thumb

So it seems Varnish 4.0 and 4.1 (more may be affected this is the limit of my testing presently) has a bug where some whitespace can through it from recognising valid configuration such as below
# ACLs to control who can access this caching proxy server<br /> acl local {<br /> "127.0.0.0"/8; /* loopback range */<br /> "192.168.1.0"/29; /* local network range 192.168.1.0-192.168.1.7 */<br /> "10.0.0.0"/8; /* For testing on own hown network - REMOVE FOR PRODUCTION */<br /> }

######################
# Urls to cache
# /api/3.0/artists/
# /api/3.0/venues/
#####################

sub vcl_recv {
# Happens before we check if we have this in cache already.

# Typically you clean up the request here, removing cookies you don’t need,
# rewriting the request, etc.

if (client.ip !~ local ) {
{error 403 “Access denied”;}
}
return (lookup);

# We only want to cache GET request
if (req.request == “GET”) {
return(hash);
}
}

 

This was due to a bad code merge cited here https://github.com/nexcess/magento-turpentine/pull/1311

You can resolve this by manually removing the whitespace by using the command below

cat default-withWhiteSpace.vcl | tr -d " \t\n\r" > default.vcl