LinuxCommandLibrary

varnishd

TLDR

Start with default backend

$ varnishd -a :80 -b localhost:8080
copy
Start with VCL configuration
$ varnishd -a :80 -f /etc/varnish/default.vcl
copy
Run in foreground
$ varnishd -F -a :80 -b localhost:8080
copy
Set cache storage size
$ varnishd -a :80 -b localhost:8080 -s malloc,[256m]
copy
Enable management interface
$ varnishd -a :80 -b localhost:8080 -T localhost:6082
copy
Set default TTL
$ varnishd -a :80 -b localhost:8080 -t [120]
copy
Set runtime parameters
$ varnishd -a :80 -b localhost:8080 -p thread_pools=[2]
copy

SYNOPSIS

varnishd [options]

DESCRIPTION

varnishd is the Varnish HTTP accelerator daemon. It acts as a reverse proxy cache, accepting HTTP requests, forwarding them to backend servers, and caching responses to serve future requests faster.
The daemon uses VCL (Varnish Configuration Language) to define caching policies, request routing, and response handling. VCL is compiled to C and loaded dynamically.
Storage backends include malloc (memory), file (disk), and persistent (survives restarts). Multiple storage backends and listening addresses can be configured.
The management interface allows runtime configuration changes, VCL loading, and statistics access via varnishadm.

PARAMETERS

-a address[:port]

Listen for client requests (default port: 80).
-b host[:port]
Backend server (default port: 8080).
-f config
VCL configuration file.
-F
Run in foreground (don't fork).
-s [name=]type[,options]
Storage backend: malloc, file, persistent.
-t ttl
Default TTL for cached objects in seconds.
-T address[:port]
Management interface address.
-S secret-file
Authentication secret for management.
-n name
Instance name and working directory.
-p param=value
Set runtime parameter.
-r param[,param...]
Make parameters read-only.
-i identity
Server identity string.
-I clifile
Execute CLI commands from file on start.

CAVEATS

Requires either -b or -f option. VCL changes require reload through management interface. Memory storage is lost on restart. Running on port 80 requires root or capabilities.

HISTORY

Varnish was created by Poul-Henning Kamp and released in 2006. It was designed from scratch for modern hardware and operating systems, using techniques like memory-mapped files and kernel-level optimizations. It has become one of the most widely deployed HTTP accelerators.

SEE ALSO

Copied to clipboard