Escape query string for varnishncsa/varnishlog

Paul Wolstenholme paul.wolstenholme at
Wed Feb 18 21:59:10 CET 2015

I'd like to run varnishncsa with some query options on startup:

varnishncsa  -a -w ${LOGFILE} -D -P ${PIDFILE} -q 'RespStatus >= 400'"

I can't seem to get the special character escaped properly in
/etc/default/varnishncsa using Ubuntu LTS 14.04.

I have tried quite a few variation of things like:
DAEMON_OPTS=" -a -w ${LOGFILE} -D -P ${PIDFILE} -q \\\'RespStatus \\\>\\\=

I can get it to work by adding a string in /etc/init.d/varnishncsa :

QUERY="'RespStatus >= 400'"

And modifying the start function:

if start-stop-daemon --start --quiet --pidfile ${PIDFILE}  -q ${QUERY} \

Anyone have any suggestion on how to properly escape a query string in the


Paul Wolstenholme
CBC Music - System Administrator
CBC  Vancouver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list