HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/thread-self/root/usr/share/doc/varnish-6.0.3/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="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>varnish-cli &#8212; Varnish version 6.0.3 documentation</title>
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></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="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="varnishadm" href="varnishadm.html" />
    <link rel="prev" title="Varnish Processing States" href="states.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <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 class="nav-item nav-item-0"><a href="../index.html">Varnish version 6.0.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Varnish Reference Manual</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <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"><span class="std std-ref">varnishd</span></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-default notranslate"><div class="highlight"><pre><span></span><span class="n">help</span> <span class="n">banner</span>
</pre></div>
</div>
<p>is equivalent to</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;help&quot;</span> <span class="n">banner</span>
</pre></div>
</div>
<p>because the double quotes only indicate the boundaries of the <code class="docutils literal notranslate"><span class="pre">help</span></code>
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 &quot; 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-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;&lt;</span> <span class="n">word</span>
     <span class="n">here</span> <span class="n">document</span>
<span class="n">word</span>
</pre></div>
</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 <code class="docutils literal notranslate"><span class="pre">&lt;&lt;</span></code> token:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cat</span> <span class="o">&lt;&lt;</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 <code class="docutils literal notranslate"><span class="pre">&lt;&lt;</span></code> and <code class="docutils literal notranslate"><span class="pre">EOF</span></code> tokens must be separated by
at least one blank:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vcl</span><span class="o">.</span><span class="n">inline</span> <span class="n">boot</span> <span class="o">&lt;&lt;</span><span class="n">EOF</span>
<span class="mi">106</span> <span class="mi">258</span>
<span class="n">Message</span> <span class="kn">from</span> <span class="nn">VCC</span><span class="o">-</span><span class="n">compiler</span><span class="p">:</span>
<span class="n">VCL</span> <span class="n">version</span> <span class="n">declaration</span> <span class="n">missing</span>
<span class="n">Update</span> <span class="n">your</span> <span class="n">VCL</span> <span class="n">to</span> <span class="n">Version</span> <span class="mi">4</span> <span class="n">syntax</span><span class="p">,</span> <span class="ow">and</span> <span class="n">add</span>
        <span class="n">vcl</span> <span class="mf">4.0</span><span class="p">;</span>
<span class="n">on</span> <span class="n">the</span> <span class="n">first</span> <span class="n">line</span> <span class="n">of</span> <span class="n">the</span> <span class="n">VCL</span> <span class="n">files</span><span class="o">.</span>
<span class="p">(</span><span class="s1">&#39;&lt;vcl.inline&gt;&#39;</span> <span class="n">Line</span> <span class="mi">1</span> <span class="n">Pos</span> <span class="mi">1</span><span class="p">)</span>
<span class="o">&lt;&lt;</span><span class="n">EOF</span>
<span class="c1">##---</span>

<span class="n">Running</span> <span class="n">VCC</span><span class="o">-</span><span class="n">compiler</span> <span class="n">failed</span><span class="p">,</span> <span class="n">exited</span> <span class="k">with</span> <span class="mi">2</span>
<span class="n">VCL</span> <span class="n">compilation</span> <span class="n">failed</span>
</pre></div>
</div>
<p>With the missing space, the here document can be added and the actual VCL
can be loaded:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vcl</span><span class="o">.</span><span class="n">inline</span> <span class="n">test</span> <span class="o">&lt;&lt;</span> <span class="n">EOF</span>
<span class="n">vcl</span> <span class="mf">4.0</span><span class="p">;</span>

<span class="n">backend</span> <span class="n">be</span> <span class="p">{</span>
        <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">&quot;localhost&quot;</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">EOF</span>
<span class="mi">200</span> <span class="mi">14</span>
<span class="n">VCL</span> <span class="n">compiled</span><span class="o">.</span>
</pre></div>
</div>
<p>When using a front-end to the Varnish-CLI like <code class="docutils literal notranslate"><span class="pre">varnishadm</span></code>, one must
take into account the double expansion happening.  First in the shell
launching the <code class="docutils literal notranslate"><span class="pre">varnishadm</span></code> 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-default notranslate"><div class="highlight"><pre><span></span><span class="n">varnishadm</span> <span class="n">param</span><span class="o">.</span><span class="n">set</span> <span class="n">cc_command</span> <span class="s1">&#39;&quot;my alternate cc command&quot;&#39;</span>

<span class="n">Change</span> <span class="n">will</span> <span class="n">take</span> <span class="n">effect</span> <span class="n">when</span> <span class="n">VCL</span> <span class="n">script</span> <span class="ow">is</span> <span class="n">reloaded</span>
</pre></div>
</div>
<p>Otherwise if you don’t quote the quotes, you may get a seemingly unrelated
error message:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">varnishadm</span> <span class="n">param</span><span class="o">.</span><span class="n">set</span> <span class="n">cc_command</span> <span class="s2">&quot;my alternate cc command&quot;</span>
<span class="n">Unknown</span> <span class="n">request</span><span class="o">.</span>
<span class="n">Type</span> <span class="s1">&#39;help&#39;</span> <span class="k">for</span> <span class="n">more</span> <span class="n">info</span><span class="o">.</span>
<span class="n">Too</span> <span class="n">many</span> <span class="n">parameters</span>

<span class="n">Command</span> <span class="n">failed</span> <span class="k">with</span> <span class="n">error</span> <span class="n">code</span> <span class="mi">105</span>
</pre></div>
</div>
<p>If you are quoting with a here document, you must wrap it inside a shell
multi-line argument:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">varnishadm</span> <span class="n">vcl</span><span class="o">.</span><span class="n">inline</span> <span class="n">test</span> <span class="s1">&#39;&lt;&lt; EOF</span>
<span class="n">vcl</span> <span class="mf">4.0</span><span class="p">;</span>

<span class="n">backend</span> <span class="n">be</span> <span class="p">{</span>
        <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">&quot;localhost&quot;</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">EOF</span><span class="s1">&#39;</span>
<span class="n">VCL</span> <span class="n">compiled</span><span class="o">.</span>
</pre></div>
</div>
<p>Other pitfalls include variable expansion of the shell invoking <code class="docutils literal notranslate"><span class="pre">varnishadm</span></code>
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 <code class="docutils literal notranslate"><span class="pre">-j</span></code> 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 <code class="docutils literal notranslate"><span class="pre">status</span> <span class="pre">-j</span></code> just contains a string in
the top-level array indicating the state of the child process
(<code class="docutils literal notranslate"><span class="pre">&quot;running&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;stopped&quot;</span></code> and so forth):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span> <span class="mi">2</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;status&quot;</span><span class="p">,</span> <span class="s2">&quot;-j&quot;</span><span class="p">],</span> <span class="mf">1538031732.632</span><span class="p">,</span> <span class="s2">&quot;running&quot;</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 <code class="docutils literal notranslate"><span class="pre">-j</span></code> 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-response"></span><h5>auth &lt;response&gt;<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-j-p-backend-pattern"></span><h5>backend.list [-j] [-p] [&lt;backend_pattern&gt;]<a class="headerlink" href="#backend-list-j-p-backend-pattern" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>List backends.  -p also shows probe status.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output.</p>
</div>
<div class="section" id="backend-set-health-backend-pattern-auto-healthy-sick">
<span id="ref-cli-backend-set-health-backend-pattern-auto-healthy-sick"></span><h5>backend.set_health &lt;backend_pattern&gt; [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-field-operator-arg-field-oper-arg"></span><h5>ban &lt;field&gt; &lt;operator&gt; &lt;arg&gt; [&amp;&amp; &lt;field&gt; &lt;oper&gt; &lt;arg&gt; …]<a class="headerlink" href="#ban-field-operator-arg-field-oper-arg" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Mark obsolete all objects where all the conditions match.</div></blockquote>
<p>See <a class="reference internal" href="vcl.html#vcl-7-ban"><span class="std std-ref">ban(STRING)</span></a> for details</p>
</div>
<div class="section" id="ban-list-j">
<span id="ref-cli-ban-list-j"></span><h5>ban.list [-j]<a class="headerlink" href="#ban-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div><blockquote>
<div>List the active bans.</div></blockquote>
<p>Unless <code class="docutils literal notranslate"><span class="pre">-j</span></code> is specified (for JSON output),  the output format is:</p>
<blockquote>
<div><ul class="simple">
<li>Time the ban was issued.</li>
<li>Objects referencing this ban.</li>
<li><code class="docutils literal notranslate"><span class="pre">C</span></code> if ban is completed = no further testing against it.</li>
<li>if <code class="docutils literal notranslate"><span class="pre">lurker</span></code> debugging is enabled:<ul>
<li><code class="docutils literal notranslate"><span class="pre">R</span></code> for req.* tests</li>
<li><code class="docutils literal notranslate"><span class="pre">O</span></code> for obj.* tests</li>
<li>Pointer to ban object</li>
</ul>
</li>
<li>Ban specification</li>
</ul>
</div></blockquote>
</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-j-command"></span><h5>help [-j] [&lt;command&gt;]<a class="headerlink" href="#help-j-command" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Show command/protocol help.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output.</p>
</div>
<div class="section" id="panic-clear-z">
<span id="ref-cli-panic-clear-z"></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-j"></span><h5>panic.show [-j]<a class="headerlink" href="#panic-show-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Return the last panic, if any.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output – the panic message is returned as an unstructured JSON string.</p>
</div>
<div class="section" id="param-set-param-value">
<span id="ref-cli-param-set-param-value"></span><h5>param.set &lt;param&gt; &lt;value&gt;<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-l-j-param-changed"></span><h5>param.show [-l|-j] [&lt;param&gt;|changed]<a class="headerlink" href="#param-show-l-j-param-changed" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Show parameters and their values.</div></blockquote>
<p>The long form with <code class="docutils literal notranslate"><span class="pre">-l</span></code> shows additional information, including documentation and minimum, maximum and default values, if defined for the parameter. JSON output is specified with <code class="docutils literal notranslate"><span class="pre">-j</span></code>, in which the information for the long form is included; only one of <code class="docutils literal notranslate"><span class="pre">-l</span></code> or <code class="docutils literal notranslate"><span class="pre">-j</span></code> is permitted. If a parameter is specified with <code class="docutils literal notranslate"><span class="pre">&lt;param&gt;</span></code>, show only that parameter. If <code class="docutils literal notranslate"><span class="pre">changed</span></code> is specified, show only those parameters whose values differ from their defaults.</p>
</div>
<div class="section" id="ping-j-timestamp">
<span id="ref-cli-ping-j-timestamp"></span><h5>ping [-j] [&lt;timestamp&gt;]<a class="headerlink" href="#ping-j-timestamp" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Keep connection alive.</div></blockquote>
<p>The response is formatted as JSON if <code class="docutils literal notranslate"><span class="pre">-j</span></code> is specified.</p>
</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-j"></span><h5>status [-j]<a class="headerlink" href="#status-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Check status of Varnish cache process.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output.</p>
</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-j"></span><h5>storage.list [-j]<a class="headerlink" href="#storage-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>List storage devices.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output.</p>
</div>
<div class="section" id="vcl-discard-configname-label">
<span id="ref-cli-vcl-discard-configname-label"></span><h5>vcl.discard &lt;configname|label&gt;<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-configname-quoted-vclstring-auto-cold-warm"></span><h5>vcl.inline &lt;configname&gt; &lt;quoted_VCLstring&gt; [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"><span class="std std-ref">Syntax</span></a>.</p>
</div></blockquote>
</div>
<div class="section" id="vcl-label-label-configname">
<span id="ref-cli-vcl-label-label-configname"></span><h5>vcl.label &lt;label&gt; &lt;configname&gt;<a class="headerlink" href="#vcl-label-label-configname" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>Apply label to configuration.</div></blockquote>
</div>
<div class="section" id="vcl-list-j">
<span id="ref-cli-vcl-list-j"></span><h5>vcl.list [-j]<a class="headerlink" href="#vcl-list-j" title="Permalink to this headline">¶</a></h5>
<blockquote>
<div>List all loaded configuration.</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">-j</span></code> specifies JSON output.</p>
</div>
<div class="section" id="vcl-load-configname-filename-auto-cold-warm">
<span id="ref-cli-vcl-load-configname-filename-auto-cold-warm"></span><h5>vcl.load &lt;configname&gt; &lt;filename&gt; [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-v-configname"></span><h5>vcl.show [-v] &lt;configname&gt;<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-configname-auto-cold-warm"></span><h5>vcl.state &lt;configname&gt; [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-use-configname-label">
<span id="ref-cli-vcl-use-configname-label"></span><h5>vcl.use &lt;configname|label&gt;<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-default notranslate"><div class="highlight"><pre><span></span><span class="n">backend</span><span class="o">.</span><span class="n">list</span> <span class="n">def</span><span class="o">*</span>
<span class="n">backend</span><span class="o">.</span><span class="n">list</span> <span class="n">b</span><span class="o">*.</span><span class="n">def</span><span class="o">*</span>
<span class="n">backend</span><span class="o">.</span><span class="n">set_health</span> <span class="n">default</span> <span class="n">sick</span>
<span class="n">backend</span><span class="o">.</span><span class="n">set_health</span> <span class="n">def</span><span class="o">*</span> <span class="n">healthy</span>
<span class="n">backend</span><span class="o">.</span><span class="n">set_health</span> <span class="o">*</span> <span class="n">auto</span>
</pre></div>
</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 “&amp;&amp;”.</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 “&gt;” or “&lt;” 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-default notranslate"><div class="highlight"><pre><span></span><span class="n">critter</span> <span class="n">phk</span><span class="o">&gt;</span> <span class="n">telnet</span> <span class="n">localhost</span> <span class="mi">1234</span>
<span class="n">Trying</span> <span class="p">::</span><span class="mf">1.</span><span class="o">..</span>
<span class="n">Trying</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="o">...</span>
<span class="n">Connected</span> <span class="n">to</span> <span class="n">localhost</span><span class="o">.</span>
<span class="n">Escape</span> <span class="n">character</span> <span class="ow">is</span> <span class="s1">&#39;^]&#39;</span><span class="o">.</span>
<span class="mi">107</span> <span class="mi">59</span>
<span class="n">ixslvvxrgkjptxmcgnnsdxsvdmvfympg</span>

<span class="n">Authentication</span> <span class="n">required</span><span class="o">.</span>

<span class="n">auth</span> <span class="mi">455</span><span class="n">ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a</span>
<span class="mi">200</span> <span class="mi">279</span>
<span class="o">-----------------------------</span>
<span class="n">Varnish</span> <span class="n">Cache</span> <span class="n">CLI</span> <span class="mf">1.0</span>
<span class="o">-----------------------------</span>
<span class="n">Linux</span><span class="p">,</span><span class="mf">4.4</span><span class="o">.</span><span class="mi">0</span><span class="o">-</span><span class="mi">1</span><span class="o">-</span><span class="n">amd64</span><span class="p">,</span><span class="n">x86_64</span><span class="p">,</span><span class="o">-</span><span class="n">jnone</span><span class="p">,</span><span class="o">-</span><span class="n">smalloc</span><span class="p">,</span><span class="o">-</span><span class="n">smalloc</span><span class="p">,</span><span class="o">-</span><span class="n">hcritbit</span>
<span class="n">varnish</span><span class="o">-</span><span class="n">trunk</span> <span class="n">revision</span> <span class="n">dc360a4</span>

<span class="n">Type</span> <span class="s1">&#39;help&#39;</span> <span class="k">for</span> <span class="n">command</span> <span class="nb">list</span><span class="o">.</span>
<span class="n">Type</span> <span class="s1">&#39;quit&#39;</span> <span class="n">to</span> <span class="n">close</span> <span class="n">CLI</span> <span class="n">session</span><span class="o">.</span>
<span class="n">Type</span> <span class="s1">&#39;start&#39;</span> <span class="n">to</span> <span class="n">launch</span> <span class="n">worker</span> <span class="n">process</span><span class="o">.</span>
</pre></div>
</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-default notranslate"><div class="highlight"><pre><span></span><span class="n">critter</span> <span class="n">phk</span><span class="o">&gt;</span> <span class="n">cat</span> <span class="o">&gt;</span> <span class="n">_</span>
<span class="n">ixslvvxrgkjptxmcgnnsdxsvdmvfympg</span>
<span class="n">foo</span>
<span class="n">ixslvvxrgkjptxmcgnnsdxsvdmvfympg</span>
<span class="o">^</span><span class="n">D</span>
<span class="n">critter</span> <span class="n">phk</span><span class="o">&gt;</span> <span class="n">hexdump</span> <span class="o">-</span><span class="n">C</span> <span class="n">_</span>
<span class="mi">00000000</span>  <span class="mi">69</span> <span class="mi">78</span> <span class="mi">73</span> <span class="mi">6</span><span class="n">c</span> <span class="mi">76</span> <span class="mi">76</span> <span class="mi">78</span> <span class="mi">72</span>  <span class="mi">67</span> <span class="mi">6</span><span class="n">b</span> <span class="mi">6</span><span class="n">a</span> <span class="mi">70</span> <span class="mi">74</span> <span class="mi">78</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">63</span>  <span class="o">|</span><span class="n">ixslvvxrgkjptxmc</span><span class="o">|</span>
<span class="mi">00000010</span>  <span class="mi">67</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">73</span> <span class="mi">64</span> <span class="mi">78</span> <span class="mi">73</span> <span class="mi">76</span>  <span class="mi">64</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">76</span> <span class="mi">66</span> <span class="mi">79</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">70</span> <span class="mi">67</span>  <span class="o">|</span><span class="n">gnnsdxsvdmvfympg</span><span class="o">|</span>
<span class="mi">00000020</span>  <span class="mi">0</span><span class="n">a</span> <span class="mi">66</span> <span class="mi">6</span><span class="n">f</span> <span class="mi">6</span><span class="n">f</span> <span class="mi">0</span><span class="n">a</span> <span class="mi">69</span> <span class="mi">78</span> <span class="mi">73</span>  <span class="mi">6</span><span class="n">c</span> <span class="mi">76</span> <span class="mi">76</span> <span class="mi">78</span> <span class="mi">72</span> <span class="mi">67</span> <span class="mi">6</span><span class="n">b</span> <span class="mi">6</span><span class="n">a</span>  <span class="o">|.</span><span class="n">foo</span><span class="o">.</span><span class="n">ixslvvxrgkj</span><span class="o">|</span>
<span class="mi">00000030</span>  <span class="mi">70</span> <span class="mi">74</span> <span class="mi">78</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">63</span> <span class="mi">67</span> <span class="mi">6</span><span class="n">e</span> <span class="mi">6</span><span class="n">e</span>  <span class="mi">73</span> <span class="mi">64</span> <span class="mi">78</span> <span class="mi">73</span> <span class="mi">76</span> <span class="mi">64</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">76</span>  <span class="o">|</span><span class="n">ptxmcgnnsdxsvdmv</span><span class="o">|</span>
<span class="mi">00000040</span>  <span class="mi">66</span> <span class="mi">79</span> <span class="mi">6</span><span class="n">d</span> <span class="mi">70</span> <span class="mi">67</span> <span class="mi">0</span><span class="n">a</span>                                 <span class="o">|</span><span class="n">fympg</span><span class="o">.|</span>
<span class="mi">00000046</span>
<span class="n">critter</span> <span class="n">phk</span><span class="o">&gt;</span> <span class="n">sha256</span> <span class="n">_</span>
<span class="n">SHA256</span> <span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="o">=</span> <span class="mi">455</span><span class="n">ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a</span>
<span class="n">critter</span> <span class="n">phk</span><span class="o">&gt;</span> <span class="n">openssl</span> <span class="n">dgst</span> <span class="o">-</span><span class="n">sha256</span> <span class="o">&lt;</span> <span class="n">_</span>
<span class="mi">455</span><span class="n">ce847f0073c7ab3b1465f74507b75d3dc064c1e7de3b71e00de9092fdc89a</span>
</pre></div>
</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-default notranslate"><div class="highlight"><pre><span></span><span class="n">vcl</span><span class="o">.</span><span class="n">inline</span> <span class="n">example</span> <span class="o">&lt;&lt;</span> <span class="n">EOF</span>
<span class="n">vcl</span> <span class="mf">4.0</span><span class="p">;</span>

<span class="n">backend</span> <span class="n">www</span> <span class="p">{</span>
    <span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">&quot;127.0.0.1&quot;</span><span class="p">;</span>
    <span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="s2">&quot;8080&quot;</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">EOF</span>
</pre></div>
</div>
<p>Ban all requests where req.url exactly matches the string /news:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ban</span> <span class="n">req</span><span class="o">.</span><span class="n">url</span> <span class="o">==</span> <span class="s2">&quot;/news&quot;</span>
</pre></div>
</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-default notranslate"><div class="highlight"><pre><span></span><span class="n">ban</span> <span class="n">req</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">host</span> <span class="o">~</span> <span class="s2">&quot;^(?i)(www</span><span class="se">\\</span><span class="s2">.)?example</span><span class="se">\\</span><span class="s2">.com$&quot;</span> <span class="o">&amp;&amp;</span> <span class="n">obj</span><span class="o">.</span><span class="n">http</span><span class="o">.</span><span class="n">set</span><span class="o">-</span><span class="n">cookie</span> <span class="o">~</span> <span class="s2">&quot;USERID=1663&quot;</span>
</pre></div>
</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"><span class="std std-ref">varnishadm</span></a></li>
<li><a class="reference internal" href="varnishd.html#varnishd-1"><span class="std std-ref">varnishd</span></a></li>
<li><a class="reference internal" href="vcl.html#vcl-7"><span class="std std-ref">VCL</span></a></li>
</ul>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <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 &lt;response&gt;</a></li>
<li><a class="reference internal" href="#backend-list-j-p-backend-pattern">backend.list [-j] [-p] [&lt;backend_pattern&gt;]</a></li>
<li><a class="reference internal" href="#backend-set-health-backend-pattern-auto-healthy-sick">backend.set_health &lt;backend_pattern&gt; [auto|healthy|sick]</a></li>
<li><a class="reference internal" href="#ban-field-operator-arg-field-oper-arg">ban &lt;field&gt; &lt;operator&gt; &lt;arg&gt; [&amp;&amp; &lt;field&gt; &lt;oper&gt; &lt;arg&gt; …]</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] [&lt;command&gt;]</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-set-param-value">param.set &lt;param&gt; &lt;value&gt;</a></li>
<li><a class="reference internal" href="#param-show-l-j-param-changed">param.show [-l|-j] [&lt;param&gt;|changed]</a></li>
<li><a class="reference internal" href="#ping-j-timestamp">ping [-j] [&lt;timestamp&gt;]</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 &lt;configname|label&gt;</a></li>
<li><a class="reference internal" href="#vcl-inline-configname-quoted-vclstring-auto-cold-warm">vcl.inline &lt;configname&gt; &lt;quoted_VCLstring&gt; [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-label-label-configname">vcl.label &lt;label&gt; &lt;configname&gt;</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 &lt;configname&gt; &lt;filename&gt; [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-show-v-configname">vcl.show [-v] &lt;configname&gt;</a></li>
<li><a class="reference internal" href="#vcl-state-configname-auto-cold-warm">vcl.state &lt;configname&gt; [auto|cold|warm]</a></li>
<li><a class="reference internal" href="#vcl-use-configname-label">vcl.use &lt;configname|label&gt;</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>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/reference/varnish-cli.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <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>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <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 class="nav-item nav-item-0"><a href="../index.html">Varnish version 6.0.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >The Varnish Reference Manual</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2010-2014, Varnish Software AS.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.6.
    </div>
  </body>
</html>