varnishd
HTTP accelerator daemon#
- Manual section: 1
SYNOPSIS#
varnishd
[-a [name=][listen_address[,PROTO|,option=value,…]]
[-A cfgfile]
[-b [host[:port]|path]]
[-C]
[-d]
[-E extension]
[-F]
[-f config]
[-h type[,options]]
[-I clifile]
[-i identity]
[-j jail[,jailoptions]]
[-l vsl]
[-M address:port]
[-n workdir]
[-P file]
[-p param=value]
[-r param[,param…]]
[-S secret-file]
[-s [name=]kind[,options]]
[-T address[:port]]
[-t TTL]
[-V]
[-W waiter]
varnishd [-x parameter|vsl|cli|builtin|optstring]
varnishd [-?]
DESCRIPTION#
The varnishd daemon accepts HTTP requests from clients, passes them on to a backend server and caches the returned documents to better satisfy future requests for the same document.
OPTIONS#
Basic options#
-a <[name=][listen_address[,PROTO|,option=value,...]]>
Generic syntax to accept client requests on a listen_address. See below for details.
Name is referenced in logs and available to vcl as local.socket. If name is not specified, a with a numerical sequence (a0, a1, etc.) is used.
Any arguments after the listen_address separated by comma are taken as either an acceptor option=value pair if containing a =, or as a PROTO(col) selection otherwise.
Valid options depend on the acceptor type, see below.
PROTO can be HTTP (the default), PROXY or HTTPS. Both version 1 and 2 of the proxy protocol can be used. When HTTPS is specified, the listener will accept TLS connections (see also -A below).
Multiple -a arguments are allowed.
If no -a argument is given, the default -a :80 will listen on all IPv4 and IPv6 interfaces.
-a <[name=][ip_address][:port][,PROTO]>
The ip_address can be a host name (localhost), an IPv4 dotted-quad 127.0.0.1) or an IPv6 address enclosed in square brackets ([::1])
The port can be a port number (80), a service name (http), or a port range (80-81). Port ranges are inclusive and cannot overlap. If port is not specified, port 80 (http) is used.
At least one of ip_address or port is required.
-a <[name=][path][,PROTO][,user=name][,group=name][,mode=octal]>
(VCL4.1 and higher)
Accept connections on a Unix domain socket. Path must be absolute (/path/to/listen.sock) or @ followed by the name of an abstract socket (@myvarnishd).
The user, group and mode sub-arguments may be used to specify the permissions of the socket file – use names for user and group, and a 3-digit octal value for mode. These sub-arguments do not apply to abstract sockets.
-A cfgfile
Load TLS configuration from the specified file. The file defines listen endpoints and their TLS settings (certificates, protocols, ciphers).
When -A is used, Varnish terminates TLS natively without needing an external TLS proxy.
Certificates can also be managed at runtime using the tls.cert.* family of CLI commands.
An alternative to -A is to use -a with the HTTPS protocol, for example -a :443,HTTPS, and then load certificates via the CLI.
-b <[host[:port]|path]>
Use the specified host as backend server. If port is not specified, the default is 8080.
If the value of -b begins with /, it is interpreted as the absolute path of a Unix domain socket to which Varnish connects. In that case, the value of -b must satisfy the conditions required for the .path field of a backend declaration. Backends with Unix socket addresses may only be used with VCL versions >= 4.1.
-b can be used only once, and not together with -f.
-f config
Use the specified VCL configuration file instead of the builtin default. See details on VCL syntax.
If a single -f option is used, then the VCL instance loaded from the file is named -boot and immediately becomes active. If more than one -f option is used, the VCL instances are named boot0, boot1 and so forth, in the order corresponding to the -f arguments, and the last one is named boot, which becomes active.
Either -b or one or more -f options must be specified, but not both, and they cannot both be left out, unless -d is used to start varnishd in debugging mode. If the empty string is specified as the sole -f option, then varnishd starts without starting the worker process, and the management process will accept CLI commands. You can also combine an empty -f option with an initialization script (-I option) and the child process will be started if there is an active VCL at the end of the initialization.
When used with a relative file name, config is searched in the vcl_path. It is possible to set this path prior to using -f options with a -p option. During startup, varnishd doesn’t complain about unsafe VCL paths: unlike the Varnish CLI that could later be accessed remotely, starting varnishd requires local privileges.
-n workdir
Runtime directory for the shared memory, compiled VCLs etc.
In performance critical applications, this directory should be on a RAM backed filesystem.
When running multiple varnishd instances, separate directories need to be used.
The default is taken from the VARNISH_DEFAULT_N environment variable.
Relative paths will be appended to /var/run.
If neither VARNISH_DEFAULT_N nor -n are present, the value is /var/run/varnishd.
Note: These defaults may be distribution specific.
Documentation options#
For these options, varnishd prints information to standard output and exits. When a -x option is used, it must be the only option (it outputs documentation in reStructuredText, aka RST).
-?
Print the usage message.
-x parameter
Print documentation of the runtime parameters (-p options), see List of Parameters.
-x vsl
Print documentation of the tags used in the Vinyld Cache shared memory log, see VSL.
-x cli
Print documentation of the command line interface, see Varnish CLI.
-x builtin
Print the contents of the default VCL program builtin.vcl.
-x optstring
Print the optstring parameter to getopt(3) to help writing wrapper scripts.
Operations options#
-F
Do not fork, run in the foreground. Only one of -F or -d can be specified, and -F cannot be used together with -C.
-T <address[:port]>
Offer a management interface on the specified address and port. See Varnish CLI for documentation of the management commands. To disable the management interface use none.
-M <address:port>
Connect to this port and offer the command line interface. Think of it as a reverse shell. When running with -M and there is no backend defined the child process (the cache) will not start initially.
-P file
Write the PID of the process to the specified file.
-i identity
Specify the identity of the Varnish server. This can be accessed using server.identity from VCL.
The server identity is used for the received-by field of Via headers generated by Varnish. For this reason, it must be a valid token as defined by the HTTP grammar.
If not specified the output of gethostname(3) is used, in which case the syntax is assumed to be correct.
-I clifile
Execute the management commands in the file given as clifile before the worker process starts, see CLI Command File_.
-E extension
Load the named extension. Extensions are modules (VMODs) which can modify varnishd behavior outside VCL, for example by adding storage- or protocol implementations. Extensions are always also VMODs, even if they do not provide any functionality to VCL, but in most cases they will.
Any VMOD can be loaded as an extension, in which case it is simply pre-loaded at startup and prevented from ever getting unloaded.
If extension contains any slashes /, it is taken as an abslute path. Otherwise, for extention ext, a vmod_ext.so is searched for in vmod_path.
varnishd startup fails if loading the extension fails for any reason.
Tuning options#
-t TTL
Specifies the default time to live (TTL) for cached objects. This is a shortcut for specifying the default_ttl run-time parameter.
-p <param=value>
Set the parameter specified by param to the specified value, see List of Parameters_ for details. This option can be used multiple times to specify multiple parameters.
-s <[name=]type[,options]>
Use the specified storage backend. See Storage Backend_ section.
This option can be used multiple times to specify multiple storage files. Name is referenced in logs, VCL, statistics, etc. If name is not specified, s0, s1 and so forth is used.
-l <vsl>
Specifies size of the space for the VSL records, shorthand for -p vsl_space=<vsl>. Scaling suffixes like K and M can be used up to (G)igabytes. See vsl_space_ for more information.
Security options#
-r <param[,param...]>
Make the listed parameters read only. This gives the system administrator a way to limit what the Varnish CLI can do. Consider making parameters such as cc_command, vcc_allow_inline_c and vmod_path read only as these can potentially be used to escalate privileges from the CLI.
-S secret-file
Path to a file containing a secret used for authorizing access to the management port. To disable authentication use none.
If this argument is not provided, a secret drawn from the system PRNG will be written to a file called _.secret in the working directory (see opt_n_) with default ownership and permissions of the user having started varnish.
Thus, users wishing to delegate control over varnish will probably want to create a custom secret file with appropriate permissions (ie. readable by a unix group to delegate control to).
-j <jail[,jailoptions]>
Specify the jailing mechanism to use. See Jail section.
Advanced, development and debugging options#
-d
Enables debugging mode: The parent process runs in the foreground with a CLI connection on stdin/stdout, and the child process must be started explicitly with a CLI command. Terminating the parent process will also terminate the child.
Only one of -d or -F can be specified, and -d cannot be used together with -C.
-C
Print VCL code compiled to C language and exit. Specify the VCL file to compile with the -f option. Either -f or -b must be used with -C, and -C cannot be used with -F or -d.
-V
Display the version number and exit. This must be the only option.
-h <type[,options]>
Specifies the hash algorithm. See Hash Algorithm section for a list of supported algorithms.
-W waiter
Specifies the waiter type to use.
Hash Algorithm#
The following hash algorithms are available:
-h critbit
self-scaling tree structure. The default hash algorithm in Varnish Cache 2.1 and onwards. In comparison to a more traditional B tree the critbit tree is almost completely lockless. Do not change this unless you are certain what you’re doing.
-h simple_list
A simple doubly-linked list. Not recommended for production use.
-h <classic[,buckets]>
A standard hash table. The hash key is the CRC32 of the object’s URL modulo the size of the hash table. Each table entry points to a list of elements which share the same hash key. The buckets parameter specifies the number of entries in the hash table. The default is 16383.
Storage Backend#
Multiple storage backends (where the cached and in-flight objects are held) can be defined, and VCL can pilot which store is used by setting the beresp.storage variable (see man vcl-var for more information).
The argument format to define storage backends is:
Storages can be used in vcl as storage.name , so, for example if myStorage was defined by -s myStorage=malloc,5G, it could be used in VCL like so:
set beresp.storage = storage.myStorage;
A special name is Transient which is the default storage for uncacheable objects as resulting from a pass, hit-for-miss or hit-for-pass.
If no -s options are given, the default is:
-s default,100m
If no Transient storage is defined, the default is an unbound default storage as if defined as:
-s Transient=default
The following storage types and options are available:
-s <default[,size]>
The default storage type resolves to umem where available and malloc otherwise.
-s <malloc[,size]>
malloc is a memory based backend.
-s <umem[,size]>
umem is a storage backend which is more efficient than malloc on platforms where it is available.
See the section on umem in chapter Storage backends of The Varnish Users Guide for details.
-s <file,path[,size[,granularity[,advice]]]>
The file backend stores data in a file on disk. The file will be accessed using mmap. Note that this storage provide no cache persistence.
The path is mandatory. If path points to a directory, a temporary file will be created in that directory and immediately unlinked. If path points to a non-existing file, the file will be created.
If size is omitted, and path points to an existing file with a size greater than zero, the size of that file will be used. If not, an error is reported.
Granularity sets the allocation block size. Defaults to the system page size or the filesystem block size, whichever is larger.
Advice tells the kernel how varnishd expects to use this mapped region so that the kernel can choose the appropriate read-ahead and caching techniques. Possible values are normal, random and sequential, corresponding to MADV_NORMAL, MADV_RANDOM and MADV_SEQUENTIAL madvise() advice argument, respectively. Defaults to random.
-s <persistent,path,size>
