Jan 18 2013
Easily validating your Varnish cache VCL file and other quick tips
I’ve been playing around with varnish lately and had to make a change in a VLC file to perform URL re-writing before following with “hashing”, lookup, and if necessary forwarding to tomcat.
For anyone wanting further information on the varnish pipeline, as well as why someone should use varnish I recommend the following two articles:
1) http://open.blogs.nytimes.com/2010/09/15/using-varnish-so-news-doesnt-break-your-server/?smid=tw-share
2) https://www.varnish-software.com/static/book/VCL_Basics.html
Validating VCL
sudo varnishd -C -f /etc/varnish/default.vcl
The following will output a message with where a syntax error exists if there is any:
[5:52:40 μμ] Menios B: VCL compilation failed
[root@test varnish]# nano default.vcl
[root@test varnish]# sudo varnishd -C -f /etc/varnish/default.vcl
Message from VCC-compiler:
Wrong argument type. Expected STRING. Got IP.
(‘input’ Line 23 Pos 58)
set req.url = req.url + “co=” + geoip.country(client.ip);
———————————————————#——
Converting client.ip, server.ip, or other types to String
VCC compiler builds expressions left to right, so seeing server.ip it has type “IP”, then you try to add a string to that and it fails.
The workaround (see above) starts out with STRING, then adds IP, but since everything, including IP, can be converted to string, that works out fine.
So, in the above error the solution is:
set req.url = req.url + “co=” + geoip.country(“”+client.ip);
If you have your own comments or tips please post below.
I will continue to provide more of these as I find them.
Redirecting varnish to new backend (emergency)
July 15, 2014 @ 1:01 am
[…] http://maythesource.com/2013/01/18/easily-validating-your-varnish-cache-vcl-file-and-other-quick-tip… […]