.. Copyright (c) 2011-2021 Varnish Software AS SPDX-License-Identifier: BSD-2-Clause See LICENSE file for full text of license .. role:: ref(emphasis) .. _varnish-cli(7): =========== varnish-cli =========== ------------------------------ Varnish Command Line Interface ------------------------------ :Manual section: 7 DESCRIPTION =========== 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. The CLI can be used for the following tasks: configuration You can upload, change and delete VCL files from the CLI. parameters 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. bans Bans are filters that are applied to keep Varnish from serving stale content. When you issue a ban Varnish will not serve any *banned* object from cache, but rather re-fetch it from its backend servers. process management 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. 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 *pushing* the CLI to that service. Please see :ref:`varnishd(1)` for details. .. _ref_syntax: Syntax ------ 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 *tokenized* before parsing, and as such arguments containing spaces must be enclosed in double quotes. It means that command parsing of :: help banner is equivalent to :: "help" banner because the double quotes only indicate the boundaries of the ``help`` token. 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. To enter characters in octals use the \\nnn syntax. Hexadecimals can be entered with the \\xnn syntax. Commands may not end with a newline when a shell-style *here document* (here-document or heredoc) is used. The format of a here document is:: << word here document word *word* can be any continuous string chosen to make sure it doesn't appear naturally in the following *here document*. Traditionally EOF or END is used. Quoting pitfalls ---------------- 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 ``<<`` token:: cat <' Line 1 Pos 1) <" or "<" for size comparisons. Prepending an operator with "!" negates the expression. 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. .. _ref_vcl_temperature: VCL Temperature --------------- 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. 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 to pay the price only for the active VCL and keep older VCLs in case you'd need to rollback to a previous version. 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. EXAMPLES ======== Load a multi-line VCL using shell-style *here document*:: vcl.inline example << EOF vcl 4.0; backend www { .host = "127.0.0.1"; .port = "8080"; } EOF Ban all requests where req.url exactly matches the string /news:: ban req.url == "/news" 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":: ban req.http.host ~ "^(?i)(www\\.)?example\\.com$" && obj.http.set-cookie ~ "USERID=1663" AUTHORS ======= This manual page was originally written by Per Buer and later modified by Federico G. Schwindt, Dridi Boukelmoune, Lasse Karstensen and Poul-Henning Kamp. SEE ALSO ======== * :ref:`varnishadm(1)` * :ref:`varnishd(1)` * :ref:`vcl(7)` * For API use of the CLI: The Reference Manual.