File: //usr/share/doc/varnish/html/reference/varnish-cli.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>varnish-cli — Varnish version 6.4.0 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '6.4.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Varnish version 6.4.0 documentation" href="../index.html" />
<link rel="up" title="The Varnish Reference Manual" href="index.html" />
<link rel="next" title="varnishadm" href="varnishadm.html" />
<link rel="prev" title="Varnish Processing States" href="states.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="varnishadm.html" title="varnishadm"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="states.html" title="Varnish Processing States"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">Varnish version 6.4.0 documentation</a> »</li>
<li><a href="index.html" accesskey="U">The Varnish Reference Manual</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="varnish-cli">
<span id="varnish-cli-7"></span><h1>varnish-cli<a class="headerlink" href="#varnish-cli" title="Permalink to this headline">¶</a></h1>
<div class="section" id="varnish-command-line-interface">
<h2>Varnish Command Line Interface<a class="headerlink" href="#varnish-command-line-interface" title="Permalink to this headline">¶</a></h2>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Manual section:</th><td class="field-body">7</td>
</tr>
</tbody>
</table>
<div class="section" id="description">
<h3>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h3>
<p>Varnish has a command line interface (CLI) which can control and change
most of the operational parameters and the configuration of Varnish,
without interrupting the running service.</p>
<p>The CLI can be used for the following tasks:</p>
<dl class="docutils">
<dt>configuration</dt>
<dd>You can upload, change and delete VCL files from the CLI.</dd>
<dt>parameters</dt>
<dd>You can inspect and change the various parameters Varnish has
available through the CLI. The individual parameters are
documented in the varnishd(1) man page.</dd>
<dt>bans</dt>
<dd>Bans are filters that are applied to keep Varnish from serving
stale content. When you issue a ban Varnish will not serve any
<em>banned</em> object from cache, but rather re-fetch it from its
backend servers.</dd>
<dt>process management</dt>
<dd>You can stop and start the cache (child) process though the
CLI. You can also retrieve the latest stack trace if the child
process has crashed.</dd>
</dl>
<p>If you invoke varnishd(1) with -T, -M or -d the CLI will be
available. In debug mode (-d) the CLI will be in the foreground, with
-T you can connect to it with varnishadm or telnet and with -M
varnishd will connect back to a listening service <em>pushing</em> the CLI to
that service. Please see <a class="reference internal" href="varnishd.html#varnishd-1"><em>varnishd</em></a> for details.</p>
<div class="section" id="syntax">
<span id="ref-syntax"></span><h4>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h4>
<p>The Varnish CLI is similar to another command line interface, the Bourne
Shell. Commands are usually terminated with a newline, and they may take
arguments. The command and its arguments are <em>tokenized</em> before parsing,
and as such arguments containing spaces must be enclosed in double quotes.</p>
<p>It means that command parsing of</p>
<div class="highlight-python"><pre>help banner</pre>
</div>
<p>is equivalent to</p>
<div class="highlight-python"><pre>"help" banner</pre>
</div>
<p>because the double quotes only indicate the boundaries of the <tt class="docutils literal"><span class="pre">help</span></tt>
token.</p>
<p>Within double quotes you can escape characters with \ (backslash). The \n,
\r, and \t get translated to newlines, carriage returns, an tabs. Double
quotes and backslashes themselves can be escaped with \" and \\
respectively.</p>
<p>To enter characters in octals use the \nnn syntax. Hexadecimals can
be entered with the \xnn syntax.</p>
<p>Commands may not end with a newline when a shell-style <em>here document</em>
(here-document or heredoc) is used. The format of a here document is:</p>
<div class="highlight-python"><pre><< word
here document
word</pre>
</div>
<p><em>word</em> can be any continuous string chosen to make sure it doesn't appear
naturally in the following <em>here document</em>. Traditionally EOF or END is
used.</p>
</div>
<div class="section" id="quoting-pitfalls">
<h4>Quoting pitfalls<a class="headerlink" href="#quoting-pitfalls" title="Permalink to this headline">¶</a></h4>
<p>Integrating with the Varnish CLI can be sometimes surprising when quoting
is involved. For instance in Bourne Shell the delimiter used with here
documents may or may not be separated by spaces from the <tt class="docutils literal"><span class="pre"><<</span></tt> token:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">cat</span> <span class="o"><<</span><span class="n">EOF</span>
<span class="n">hello</span>
<span class="n">world</span>
<span class="n">EOF</span>
<span class="n">hello</span>
<span class="n">world</span>
</pre></div>
</div>
<p>With the Varnish CLI, the <tt class="docutils literal"><span class="pre"><<</span></tt> and <tt class="docutils literal"><span class="pre">EOF</span></tt> tokens must be separated by
at least one blank:</p>
<div class="highlight-python"><pre>vcl.inline boot <<EOF
106 258
Message from VCC-compiler:
VCL version declaration missing
Update your VCL to Version 4 syntax, and add
vcl 4.0;
on the first line of the VCL files.
('<vcl.inline>' Line 1 Pos 1)
<<EOF
##---
Running VCC-compiler failed, exited with 2
VCL compilation failed</pre>
</div>
<p>With the missing space, the here document can be added and the actual VCL
can be loaded:</p>
<div class="highlight-python"><pre>vcl.inline test << EOF
vcl 4.0;
backend be {
.host = "localhost";
}
EOF
200 14
VCL compiled.</pre>
</div>
<p>When using a front-end to the Varnish-CLI like <tt class="docutils literal"><span class="pre">varnishadm</span></tt>, one must
take into account the double expansion happening. First in the shell
launching the <tt class="docutils literal"><span class="pre">varnishadm</span></tt> command and then in the Varnish CLI itself.
When a command's parameter require spaces, you need to ensure that the
Varnish CLI will see the double quotes:</p>
<div class="highlight-python"><pre>varnishadm param.set cc_command '"my alternate cc command"'
Change will take effect when VCL script is reloaded</pre>
</div>
<p>Otherwise if you don't quote the quotes, you may get a seemingly unrelated
error message:</p>
<div class="highlight-python"><pre>varnishadm param.set cc_command "my alternate cc command"
Unknown request.
Type 'help' for more info.
Too many parameters
Command failed with error code 105</pre>
</div>
<p>If you are quoting with a here document, you must wrap it inside a shell
multi-line argument:</p>
<div class="highlight-python"><pre>varnishadm vcl.inline test '<< EOF
vcl 4.0;
backend be {
.host = "localhost";
}
EOF'
VCL compiled.</pre>
</div>
<p>Other pitfalls include variable expansion of the shell invoking <tt class="docutils literal"><span class="pre">varnishadm</span></tt>
but this is not directly related to the Varnish CLI. If you get the quoting
right you should be fine even with complex commands.</p>
</div>
<div class="section" id="json">
<h4>JSON<a class="headerlink" href="#json" title="Permalink to this headline">¶</a></h4>
<p>A number of commands with informational responses support a <tt class="docutils literal"><span class="pre">-j</span></tt> parameter
for JSON output, as specified below. The top-level structure of the JSON
response is an array with these first three elements:</p>
<ul class="simple">
<li>A version number for the JSON format (integer)</li>
<li>An array of strings that comprise the CLI command just received</li>
<li>The time at which the response was generated, as a Unix epoch time
in seconds with millisecond precision (floating point)</li>
</ul>
<p>The remaining elements of the array form the data that are specific to
the CLI command, and their structure and content depend on the
command.</p>
<p>For example, the response to <tt class="docutils literal"><span class="pre">status</span> <span class="pre">-j</span></tt> just contains a string in
the top-level array indicating the state of the child process
(<tt class="docutils literal"><span class="pre">"running"</span></tt>, <tt class="docutils literal"><span class="pre">"stopped"</span></tt> and so forth):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span> <span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="s">"status"</span><span class="p">,</span> <span class="s">"-j"</span><span class="p">],</span> <span class="mf">1538031732.632</span><span class="p">,</span> <span class="s">"running"</span>
<span class="p">]</span>
</pre></div>
</div>
<p>The JSON responses to other commands may have longer lists of
elements, which may have simple data types or form structured objects.</p>
<p>JSON output is only returned if command execution was successful. The
output for an error response is always the same as it would have been
for the command without the <tt class="docutils literal"><span class="pre">-j</span></tt> parameter.</p>
</div>
<div class="section" id="commands">
<h4>Commands<a class="headerlink" href="#commands" title="Permalink to this headline">¶</a></h4>
<div class="section" id="auth-response">
<span id="ref-cli-auth"></span><h5>auth <response><a class="headerlink" href="#auth-response" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Authenticate.</div></blockquote>
</div>
<div class="section" id="backend-list-j-p-backend-pattern">
<span id="ref-cli-backend-list"></span><h5>backend.list [-j] [-p] [<backend_pattern>]<a class="headerlink" href="#backend-list-j-p-backend-pattern" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>List backends.</p>
<p><tt class="docutils literal"><span class="pre">-p</span></tt> also shows probe status.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output.</p>
<p>Unless <tt class="docutils literal"><span class="pre">-j</span></tt> is specified for JSON output, the output format is five columns of dynamic width, separated by white space with the fields:</p>
<ul>
<li><p class="first">Backend name</p>
</li>
<li><p class="first">Admin: How health state is determined:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">healthy</span></tt>: Set <tt class="docutils literal"><span class="pre">healthy</span></tt> through <tt class="docutils literal"><span class="pre">backend.set_health</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">sick</span></tt>: Set <tt class="docutils literal"><span class="pre">sick</span></tt> through <tt class="docutils literal"><span class="pre">backend.set_health</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">probe</span></tt>: Health state determined by a probe or some other
dynamic mechanism.</li>
<li><tt class="docutils literal"><span class="pre">deleted</span></tt>: Backend has been deleted, but not yet cleaned
up.</li>
</ul>
<p>Admin has precedence over Health</p>
</li>
<li><p class="first">Probe <tt class="docutils literal"><span class="pre">X/Y</span></tt>: <em>X</em> out of <em>Y</em> checks have succeeded</p>
<p><em>X</em> and <em>Y</em> are backend specific and may represent probe checks,
other backends or any other metric.</p>
<p>If there is no probe or the director does not provide details on
probe check results, <tt class="docutils literal"><span class="pre">0/0</span></tt> is output.</p>
</li>
<li><p class="first">Health: Probe health state</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">healthy</span></tt></li>
<li><tt class="docutils literal"><span class="pre">sick</span></tt></li>
</ul>
<p>If there is no probe, <tt class="docutils literal"><span class="pre">healthy</span></tt> is output.</p>
</li>
<li><p class="first">Last change: Timestamp when the health state last changed.</p>
</li>
</ul>
<p>The health state reported here is generic. A backend's health may also depend on the context it is being used in (e.g. the object's hash), so the actual health state as visible from VCL (e.g. using <tt class="docutils literal"><span class="pre">std.healthy()</span></tt>) may differ.</p>
<p>For <tt class="docutils literal"><span class="pre">-j</span></tt>, the object members should be self explanatory,
matching the fields described above. <tt class="docutils literal"><span class="pre">probe_message</span></tt> has the
format <tt class="docutils literal"><span class="pre">[X,</span> <span class="pre">Y,</span> <span class="pre">"state"]</span></tt> as described above for Probe. JSON
Probe details (<tt class="docutils literal"><span class="pre">-j</span> <span class="pre">-p</span></tt> arguments) are director specific.</p>
</div></blockquote>
</div>
<div class="section" id="backend-set-health-backend-pattern-auto-healthy-sick">
<span id="ref-cli-backend-set-health"></span><h5>backend.set_health <backend_pattern> [auto|healthy|sick]<a class="headerlink" href="#backend-set-health-backend-pattern-auto-healthy-sick" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Set health status on the backends.</div></blockquote>
</div>
<div class="section" id="ban-field-operator-arg-field-oper-arg">
<span id="ref-cli-ban"></span><h5>ban <field> <operator> <arg> [&& <field> <oper> <arg> ...]<a class="headerlink" href="#ban-field-operator-arg-field-oper-arg" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Mark obsolete all objects where all the conditions match.</p>
<p>See <a class="reference internal" href="vcl.html#vcl-7-ban"><em>ban(STRING)</em></a> for details</p>
</div></blockquote>
</div>
<div class="section" id="ban-list-j">
<span id="ref-cli-ban-list"></span><h5>ban.list [-j]<a class="headerlink" href="#ban-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>List the active bans.</p>
<p>Unless <tt class="docutils literal"><span class="pre">-j</span></tt> is specified for JSON output, the output format is:</p>
<ul class="simple">
<li>Time the ban was issued.</li>
<li>Objects referencing this ban.</li>
<li><tt class="docutils literal"><span class="pre">C</span></tt> if ban is completed = no further testing against it.</li>
<li>if <tt class="docutils literal"><span class="pre">lurker</span></tt> debugging is enabled:<ul>
<li><tt class="docutils literal"><span class="pre">R</span></tt> for req.* tests</li>
<li><tt class="docutils literal"><span class="pre">O</span></tt> for obj.* tests</li>
<li>Pointer to ban object</li>
</ul>
</li>
<li>Ban specification</li>
</ul>
<p>Durations of ban specifications get normalized, for example "7d" gets changed into "1w".</p>
</div></blockquote>
</div>
<div class="section" id="banner">
<span id="ref-cli-banner"></span><h5>banner<a class="headerlink" href="#banner" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Print welcome banner.</div></blockquote>
</div>
<div class="section" id="help-j-command">
<span id="ref-cli-help"></span><h5>help [-j] [<command>]<a class="headerlink" href="#help-j-command" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Show command/protocol help.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output.</p>
</div></blockquote>
</div>
<div class="section" id="panic-clear-z">
<span id="ref-cli-panic-clear"></span><h5>panic.clear [-z]<a class="headerlink" href="#panic-clear-z" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Clear the last panic, if any, -z will clear related varnishstat counter(s)</div></blockquote>
</div>
<div class="section" id="panic-show-j">
<span id="ref-cli-panic-show"></span><h5>panic.show [-j]<a class="headerlink" href="#panic-show-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Return the last panic, if any.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output -- the panic message is returned as an unstructured JSON string.</p>
</div></blockquote>
</div>
<div class="section" id="param-reset-param">
<span id="ref-cli-param-reset"></span><h5>param.reset <param><a class="headerlink" href="#param-reset-param" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Reset parameter to default value.</div></blockquote>
</div>
<div class="section" id="param-set-param-value">
<span id="ref-cli-param-set"></span><h5>param.set <param> <value><a class="headerlink" href="#param-set-param-value" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Set parameter value.</div></blockquote>
</div>
<div class="section" id="param-show-l-j-param-changed">
<span id="ref-cli-param-show"></span><h5>param.show [-l|-j] [<param>|changed]<a class="headerlink" href="#param-show-l-j-param-changed" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Show parameters and their values.</p>
<p>The long form with <tt class="docutils literal"><span class="pre">-l</span></tt> shows additional information, including documentation and minimum, maximum and default values, if defined for the parameter. JSON output is specified with <tt class="docutils literal"><span class="pre">-j</span></tt>, in which the information for the long form is included; only one of <tt class="docutils literal"><span class="pre">-l</span></tt> or <tt class="docutils literal"><span class="pre">-j</span></tt> is permitted. If a parameter is specified with <tt class="docutils literal"><span class="pre"><param></span></tt>, show only that parameter. If <tt class="docutils literal"><span class="pre">changed</span></tt> is specified, show only those parameters whose values differ from their defaults.</p>
</div></blockquote>
</div>
<div class="section" id="pid-j">
<span id="ref-cli-pid"></span><h5>pid [-j]<a class="headerlink" href="#pid-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Show the pid of the master process, and the worker if it's running.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output.</p>
</div></blockquote>
</div>
<div class="section" id="ping-j-timestamp">
<span id="ref-cli-ping"></span><h5>ping [-j] [<timestamp>]<a class="headerlink" href="#ping-j-timestamp" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Keep connection alive.</p>
<p>The response is formatted as JSON if <tt class="docutils literal"><span class="pre">-j</span></tt> is specified.</p>
</div></blockquote>
</div>
<div class="section" id="quit">
<span id="ref-cli-quit"></span><h5>quit<a class="headerlink" href="#quit" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Close connection.</div></blockquote>
</div>
<div class="section" id="start">
<span id="ref-cli-start"></span><h5>start<a class="headerlink" href="#start" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Start the Varnish cache process.</div></blockquote>
</div>
<div class="section" id="status-j">
<span id="ref-cli-status"></span><h5>status [-j]<a class="headerlink" href="#status-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Check status of Varnish cache process.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output.</p>
</div></blockquote>
</div>
<div class="section" id="stop">
<span id="ref-cli-stop"></span><h5>stop<a class="headerlink" href="#stop" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Stop the Varnish cache process.</div></blockquote>
</div>
<div class="section" id="storage-list-j">
<span id="ref-cli-storage-list"></span><h5>storage.list [-j]<a class="headerlink" href="#storage-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>List storage devices.</p>
<p><tt class="docutils literal"><span class="pre">-j</span></tt> specifies JSON output.</p>
</div></blockquote>
</div>
<div class="section" id="vcl-discard-configname-label">
<span id="ref-cli-vcl-discard"></span><h5>vcl.discard <configname|label><a class="headerlink" href="#vcl-discard-configname-label" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Unload the named configuration (when possible).</div></blockquote>
</div>
<div class="section" id="vcl-inline-configname-quoted-vclstring-auto-cold-warm">
<span id="ref-cli-vcl-inline"></span><h5>vcl.inline <configname> <quoted_VCLstring> [auto|cold|warm]<a class="headerlink" href="#vcl-inline-configname-quoted-vclstring-auto-cold-warm" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>Compile and load the VCL data under the name provided.</p>
<p>Multi-line VCL can be input using the here document <a class="reference internal" href="#ref-syntax"><em>Syntax</em></a>.</p>
</div></blockquote>
</div>
<div class="section" id="vcl-label-label-configname">
<span id="ref-cli-vcl-label"></span><h5>vcl.label <label> <configname><a class="headerlink" href="#vcl-label-label-configname" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Apply label to configuration.</div></blockquote>
<p>A VCL label is like a UNIX symbolic link, a name without substance, which points to another VCL.</p>
<p>Labels are mandatory whenever one VCL references another.</p>
</div>
<div class="section" id="vcl-list-j">
<span id="ref-cli-vcl-list"></span><h5>vcl.list [-j]<a class="headerlink" href="#vcl-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><p>List all loaded configuration.</p>
<p>Unless <tt class="docutils literal"><span class="pre">-j</span></tt> is specified for JSON output, the output format is five or seven columns of dynamic width, separated by white space with the fields:</p>
<ul class="simple">
<li>status: active, available or discarded</li>
<li>state: label, cold, warm, or auto</li>
<li>temperature: init, cold, warm, busy or cooling</li>
<li>busy: number of references to this vcl (integer)</li>
<li>name: the name given to this vcl or label</li>
<li>[ <tt class="docutils literal"><span class="pre"><-</span></tt> | <tt class="docutils literal"><span class="pre">-></span></tt> ] and label info last two fields)<ul>
<li><tt class="docutils literal"><span class="pre">-></span></tt> <vcl> : label "points to" the named <vcl></li>
<li><tt class="docutils literal"><span class="pre"><-</span></tt> (<n> label[s]): the vcl has <n> label(s)</li>
</ul>
</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="vcl-load-configname-filename-auto-cold-warm">
<span id="ref-cli-vcl-load"></span><h5>vcl.load <configname> <filename> [auto|cold|warm]<a class="headerlink" href="#vcl-load-configname-filename-auto-cold-warm" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Compile and load the VCL file under the name provided.</div></blockquote>
</div>
<div class="section" id="vcl-show-v-configname">
<span id="ref-cli-vcl-show"></span><h5>vcl.show [-v] <configname><a class="headerlink" href="#vcl-show-v-configname" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Display the source code for the specified configuration.</div></blockquote>
</div>
<div class="section" id="vcl-state-configname-auto-cold-warm">
<span id="ref-cli-vcl-state"></span><h5>vcl.state <configname> [auto|cold|warm]<a class="headerlink" href="#vcl-state-configname-auto-cold-warm" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Force the state of the named configuration.</div></blockquote>
</div>
<div class="section" id="vcl-symtab">
<span id="ref-cli-vcl-symtab"></span><h5>vcl.symtab<a class="headerlink" href="#vcl-symtab" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Dump the VCL symbol-tables.</div></blockquote>
</div>
<div class="section" id="vcl-use-configname-label">
<span id="ref-cli-vcl-use"></span><h5>vcl.use <configname|label><a class="headerlink" href="#vcl-use-configname-label" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Switch to the named configuration immediately.</div></blockquote>
</div>
</div>
<div class="section" id="backend-pattern">
<h4>Backend Pattern<a class="headerlink" href="#backend-pattern" title="Permalink to this headline">¶</a></h4>
<p>A backend pattern can be a backend name or a combination of a VCL name
and backend name in "VCL.backend" format. If the VCL name is omitted,
the active VCL is assumed. Partial matching on the backend and VCL
names is supported using shell-style wilcards, e.g. asterisk (*).</p>
<p>Examples:</p>
<div class="highlight-python"><pre>backend.list def*
backend.list b*.def*
backend.set_health default sick
backend.set_health def* healthy
backend.set_health * auto</pre>
</div>
</div>
<div class="section" id="ban-expressions">
<h4>Ban Expressions<a class="headerlink" href="#ban-expressions" title="Permalink to this headline">¶</a></h4>
<p>A ban expression consists of one or more conditions. A condition
consists of a field, an operator, and an argument. Conditions can be
ANDed together with "&&".</p>
<p>A field can be any of the variables from VCL, for instance req.url,
req.http.host or obj.http.set-cookie.</p>
<p>Operators are "==" for direct comparison, "~" for a regular
expression match, and ">" or "<" for size comparisons. Prepending
an operator with "!" negates the expression.</p>
<p>The argument could be a quoted string, a regexp, or an integer.
Integers can have "KB", "MB", "GB" or "TB" appended for size related
fields.</p>
</div>
<div class="section" id="vcl-temperature">
<span id="ref-vcl-temperature"></span><h4>VCL Temperature<a class="headerlink" href="#vcl-temperature" title="Permalink to this headline">¶</a></h4>
<p>A VCL program goes through several states related to the different
commands: it can be loaded, used, and later discarded. You can load
several VCL programs and switch at any time from one to another. There
is only one active VCL, but the previous active VCL will be maintained
active until all its transactions are over.</p>
<p>Over time, if you often refresh your VCL and keep the previous
versions around, resource consumption will increase, you can't escape
that. However, most of the time you want only one to pay the price only
for the active VCL and keep older VCLs in case you'd need to rollback
to a previous version.</p>
<p>The VCL temperature allows you to minimize the footprint of inactive
VCLs. Once a VCL becomes cold, Varnish will release all the resources
that can be be later reacquired. You can manually set the temperature
of a VCL or let varnish
automatically handle it.</p>
</div>
<div class="section" id="scripting">
<h4>Scripting<a class="headerlink" href="#scripting" title="Permalink to this headline">¶</a></h4>
<p>If you are going to write a script that talks CLI to varnishd, the
include/cli.h contains the relevant magic numbers.</p>
<p>One particular magic number to know, is that the line with the status
code and length field always is exactly 13 characters long, including
the NL character.</p>
<p>The varnishapi library contains functions to implement the basics of
the CLI protocol, see the <cite>vcli.h</cite> include file.</p>
</div>
<div class="section" id="authentication-with-s">
<span id="ref-psk-auth"></span><h4>Authentication with -S<a class="headerlink" href="#authentication-with-s" title="Permalink to this headline">¶</a></h4>
<p>If the -S secret-file is given as argument to varnishd, all network
CLI connections must authenticate, by proving they know the contents
of that file.</p>
<p>The file is read at the time the auth command is issued and the
contents is not cached in varnishd, so it is possible to update the
file on the fly.</p>
<p>Use the unix file permissions to control access to the file.</p>
<p>An authenticated session looks like this:</p>
<div class="highlight-python"><pre>critter phk> telnet localhost 1234
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
107 59
ixslvvxrgkjptxmcgnnsdxsvdmvfympg
Authentication required.
auth 455ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a
200 279
-----------------------------
Varnish Cache CLI 1.0
-----------------------------
Linux,4.4.0-1-amd64,x86_64,-jnone,-smalloc,-smalloc,-hcritbit
varnish-trunk revision dc360a4
Type 'help' for command list.
Type 'quit' to close CLI session.
Type 'start' to launch worker process.</pre>
</div>
<p>The CLI status of 107 indicates that authentication is necessary. The
first 32 characters of the response text is the challenge
"ixsl...mpg". The challenge is randomly generated for each CLI
connection, and changes each time a 107 is emitted.</p>
<p>The most recently emitted challenge must be used for calculating the
authenticator "455c...c89a".</p>
<p>The authenticator is calculated by applying the SHA256 function to the
following byte sequence:</p>
<ul class="simple">
<li>Challenge string</li>
<li>Newline (0x0a) character.</li>
<li>Contents of the secret file</li>
<li>Challenge string</li>
<li>Newline (0x0a) character.</li>
</ul>
<p>and dumping the resulting digest in lower-case hex.</p>
<p>In the above example, the secret file contained foon and thus:</p>
<div class="highlight-python"><pre>critter phk> cat > _
ixslvvxrgkjptxmcgnnsdxsvdmvfympg
foo
ixslvvxrgkjptxmcgnnsdxsvdmvfympg
^D
critter phk> hexdump -C _
00000000 69 78 73 6c 76 76 78 72 67 6b 6a 70 74 78 6d 63 |ixslvvxrgkjptxmc|
00000010 67 6e 6e 73 64 78 73 76 64 6d 76 66 79 6d 70 67 |gnnsdxsvdmvfympg|
00000020 0a 66 6f 6f 0a 69 78 73 6c 76 76 78 72 67 6b 6a |.foo.ixslvvxrgkj|
00000030 70 74 78 6d 63 67 6e 6e 73 64 78 73 76 64 6d 76 |ptxmcgnnsdxsvdmv|
00000040 66 79 6d 70 67 0a |fympg.|
00000046
critter phk> sha256 _
SHA256 (_) = 455ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a
critter phk> openssl dgst -sha256 < _
455ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a</pre>
</div>
<p>The sourcefile lib/libvarnish/cli_auth.c contains a useful function
which calculates the response, given an open filedescriptor to the
secret file, and the challenge string.</p>
</div>
</div>
<div class="section" id="examples">
<h3>EXAMPLES<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
<p>Load a multi-line VCL using shell-style <em>here document</em>:</p>
<div class="highlight-python"><pre>vcl.inline example << EOF
vcl 4.0;
backend www {
.host = "127.0.0.1";
.port = "8080";
}
EOF</pre>
</div>
<p>Ban all requests where req.url exactly matches the string /news:</p>
<div class="highlight-python"><pre>ban req.url == "/news"</pre>
</div>
<p>Ban all documents where the serving host is "example.com" or
"www.example.com", and where the Set-Cookie header received from the
backend contains "USERID=1663":</p>
<div class="highlight-python"><pre>ban req.http.host ~ "^(?i)(www\\.)?example\\.com$" && obj.http.set-cookie ~ "USERID=1663"</pre>
</div>
</div>
<div class="section" id="authors">
<h3>AUTHORS<a class="headerlink" href="#authors" title="Permalink to this headline">¶</a></h3>
<p>This manual page was originally written by Per Buer and later modified
by Federico G. Schwindt, Dridi Boukelmoune, Lasse Karstensen and
Poul-Henning Kamp.</p>
</div>
<div class="section" id="see-also">
<h3>SEE ALSO<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li><a class="reference internal" href="varnishadm.html#varnishadm-1"><em>varnishadm</em></a></li>
<li><a class="reference internal" href="varnishd.html#varnishd-1"><em>varnishd</em></a></li>
<li><a class="reference internal" href="vcl.html#vcl-7"><em>VCL</em></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">varnish-cli</a><ul>
<li><a class="reference internal" href="#varnish-command-line-interface">Varnish Command Line Interface</a><ul>
<li><a class="reference internal" href="#description">DESCRIPTION</a><ul>
<li><a class="reference internal" href="#syntax">Syntax</a></li>
<li><a class="reference internal" href="#quoting-pitfalls">Quoting pitfalls</a></li>
<li><a class="reference internal" href="#json">JSON</a></li>
<li><a class="reference internal" href="#commands">Commands</a><ul>
<li><a class="reference internal" href="#auth-response">auth <response></a></li>
<li><a class="reference internal" href="#backend-list-j-p-backend-pattern">backend.list [-j] [-p] [<backend_pattern>]</a></li>
<li><a class="reference internal" href="#backend-set-health-backend-pattern-auto-healthy-sick">backend.set_health <backend_pattern> [auto|healthy|sick]</a></li>
<li><a class="reference internal" href="#ban-field-operator-arg-field-oper-arg">ban <field> <operator> <arg> [&& <field> <oper> <arg> ...]</a></li>
<li><a class="reference internal" href="#ban-list-j">ban.list [-j]</a></li>
<li><a class="reference internal" href="#banner">banner</a></li>
<li><a class="reference internal" href="#help-j-command">help [-j] [<command>]</a></li>
<li><a class="reference internal" href="#panic-clear-z">panic.clear [-z]</a></li>
<li><a class="reference internal" href="#panic-show-j">panic.show [-j]</a></li>
<li><a class="reference internal" href="#param-reset-param">param.reset <param></a></li>
<li><a class="reference internal" href="#param-set-param-value">param.set <param> <value></a></li>
<li><a class="reference internal" href="#param-show-l-j-param-changed">param.show [-l|-j] [<param>|changed]</a></li>
<li><a class="reference internal" href="#pid-j">pid [-j]</a></li>
<li><a class="reference internal" href="#ping-j-timestamp">ping [-j] [<timestamp>]</a></li>
<li><a class="reference internal" href="#quit">quit</a></li>
<li><a class="reference internal" href="#start">start</a></li>
<li><a class="reference internal" href="#status-j">status [-j]</a></li>
<li><a class="reference internal" href="#stop">stop</a></li>
<li><a class="reference internal" href="#storage-list-j">storage.list [-j]</a></li>
<li><a class="reference internal" href="#vcl-discard-configname-label">vcl.discard <configname|label></a></li>
<li><a class="reference internal" href="#vcl-inline-configname-quoted-vclstring-auto-cold-warm">vcl.inline <configname> <quoted_VCLstring> [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-label-label-configname">vcl.label <label> <configname></a></li>
<li><a class="reference internal" href="#vcl-list-j">vcl.list [-j]</a></li>
<li><a class="reference internal" href="#vcl-load-configname-filename-auto-cold-warm">vcl.load <configname> <filename> [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-show-v-configname">vcl.show [-v] <configname></a></li>
<li><a class="reference internal" href="#vcl-state-configname-auto-cold-warm">vcl.state <configname> [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-symtab">vcl.symtab</a></li>
<li><a class="reference internal" href="#vcl-use-configname-label">vcl.use <configname|label></a></li>
</ul>
</li>
<li><a class="reference internal" href="#backend-pattern">Backend Pattern</a></li>
<li><a class="reference internal" href="#ban-expressions">Ban Expressions</a></li>
<li><a class="reference internal" href="#vcl-temperature">VCL Temperature</a></li>
<li><a class="reference internal" href="#scripting">Scripting</a></li>
<li><a class="reference internal" href="#authentication-with-s">Authentication with -S</a></li>
</ul>
</li>
<li><a class="reference internal" href="#examples">EXAMPLES</a></li>
<li><a class="reference internal" href="#authors">AUTHORS</a></li>
<li><a class="reference internal" href="#see-also">SEE ALSO</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="states.html"
title="previous chapter">Varnish Processing States</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="varnishadm.html"
title="next chapter">varnishadm</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/reference/varnish-cli.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="varnishadm.html" title="varnishadm"
>next</a> |</li>
<li class="right" >
<a href="states.html" title="Varnish Processing States"
>previous</a> |</li>
<li><a href="../index.html">Varnish version 6.4.0 documentation</a> »</li>
<li><a href="index.html" >The Varnish Reference Manual</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2010-2014, Varnish Software AS.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>