A couple VCL changes when upgrading to Varnish 3
The error messages Varnish provides are very informative.
tail -f /var/log/varnish/current
2014-03-02_03:52:40.47449 --------------------########-----------------------
2014-03-02_03:52:40.47449
2014-03-02_03:52:40.47450 Running VCC-compiler failed, exit 1
2014-03-02_03:52:40.47474
2014-03-02_03:52:40.47476 VCL compilation failed
2014-03-02_03:52:41.49353 Message from VCC-compiler:
2014-03-02_03:52:41.49356 Unknown variable 'req.hash'
2014-03-02_03:52:41.49360 At: ('/etc/varnish/example-includes/device-detect/device-detect.vcl' Line 61 Pos 21)
2014-03-02_03:52:41.49361 set req.hash += req.http.X-Device;
This change was clearly documented, and made in a few places:
https://www.varnish-cache.org/docs/3.0/installation/upgrade.html#req-hash-is-replaced-with-hash-data
So changed:
# Add the device to the hash (if its a mobile device)
sub vcl_hash {
if (req.http.X-Device ~ "^mobile") {
set req.hash += req.http.X-Device;
}
}
to:
# Add the device to the hash (if its a mobile device)
sub vcl_hash {
if (req.http.X-Device ~ "^mobile") {
hash_data(req.http.X-Device);
}
}
Note: If you get the error "Unknown variable 'hash_data'" be sure you haven't left "set" before hash_data.
Also had to make similar changes to (and where you will be more likely to) our /etc/varnish/sites/example.vcl
The other error was "Expected ';' got 'obj.status'" and i couldn't
figure it out, so i removed the whole custom error message function that had it. (Same approach taken here.)
Comments
Post new comment