### Starting and Reloading Varnish Service Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/tutorial/starting_varnish.rst Commands to start the Varnish service and reload its configuration after making changes. Assumes Varnish is installed and configured. ```bash service varnish start service varnish reload ``` -------------------------------- ### Automated Server Setup with Shell Scripts Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/dev-guide/homepage_dogfood.rst This script automates the setup of FreeBSD servers and jails for Varnish Cache. It includes steps for installing FreeBSD, configuring networking, setting the clock, installing Git, cloning a private repository, configuring the host, and building jails for Tools, Hitch, and Varnish. The process aims for a quick and reproducible system deployment. ```shell # Install FreeBSD (if not already done by hosting) # Configure networking (if not already done by hosting) # Set the clock service ntpdate forcestart # Get git env ASSUME_ALWAYS_YES=yes pkg install git # Clone the private git repo git clone ssh://example.com/root/Admin # Edit the machines IP numbers in /etc/pf.conf # Configure the host sh build_host.sh |& tee _.bh # Build the jails foreach i (Tools Hitch Varnish) (cd $i ; sh build* |& tee _.bj) end ``` -------------------------------- ### Varnish Default Configuration (VCL) Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/tutorial/starting_varnish.rst The default Varnish Configuration Language (VCL) file structure, defining the backend server for requests. This example shows how to set the host and port for the backend. ```vcl vcl 4.0; backend default { .host = "127.0.0.1"; .port = "8080"; } ``` ```vcl vcl 4.0; backend default { .host = "www.varnish-cache.org"; .port = "80"; } ``` -------------------------------- ### Varnish Command Execution Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/index.rst Demonstrates how to execute a Varnish command to check its version. This is a common task for verifying installation and understanding the running version of Varnish. ```shell $ /opt/varnish/sbin/varnishd -V varnishd (varnish-7.7.0 revision 1234567) Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2025 Varnish Software ``` -------------------------------- ### Varnish VCL: Basic User-Agent Detection Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/devicedetection.rst A simple VCL example demonstrating how to set the 'X-UA-Device' header based on a basic User-Agent string match for iPhones. ```VCL sub vcl_recv { if (req.http.User-Agent ~ "(?i)iphone") { set req.http.X-UA-Device = "mobile-iphone"; } } ``` -------------------------------- ### Sphinx Build Output Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/dev-guide/homepage_contrib.rst Example output from running 'make html' to build the Sphinx documentation, showing the build process and success message. ```bash sphinx-build -b html -d build/doctrees source build/html Running Sphinx v1.2.3 loading pickled environment... done building [html]: targets for 1 source files that are out of date updating environment: 0 added, 1 changed, 0 removed reading sources... [100%] tips/contribdoc/index looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done writing output... [100%] tips/index writing additional files... genindex search copying static files... done copying extra files... done dumping search index... done dumping object inventory... done build succeeded. ``` -------------------------------- ### Varnish Test Environment Setup Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishtest.rst Configures essential environment variables for running Varnish tests using pkg-config to locate Varnish installation paths and setting up the VMOD path. ```shell export PKG_CONFIG_PATH=/path/to/install/lib/pkgconfig BINDIR="$(pkg-config --variable=bindir varnishapi)" SBINDIR="$(pkg-config --variable=sbindir varnishapi)" PATH="$SBINDIR:$BINDIR:$PATH" VMODDIR="$(pkg-config --variable=vmoddir varnishapi)" VMOD_PATH="/path/to/your/vmod/build/dir:$VMODDIR" varnishtest -p vmod_path="$VMOD_PATH" ... ``` -------------------------------- ### Install Build Dependencies on FreeBSD Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs necessary packages for building Varnish from source on FreeBSD using pkg. ```shell pkg install git automake pkgconf py39-sphinx py39-docutils pcre2 libtool ``` -------------------------------- ### Install Alabaster Theme Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/dev-guide/homepage_contrib.rst Instructions for installing the Alabaster theme for Sphinx using pip and linking it to Sphinx's theme directory. ```bash $ sudo pip install alabaster ``` ```bash $ cd /usr/share/sphinx/themes $ ln -s /usr/local/lib/python2.7/dist-packages/alabaster ``` -------------------------------- ### Install Varnish 6 from FreeBSD Package Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_freebsd.rst Installs the Varnish 6 package on FreeBSD using the pkg command. ```bash pkg install varnish6 ``` -------------------------------- ### Install Sphinx on RHEL/CentOS <= 7 Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs Sphinx, jemalloc-devel, and libunwind-devel from default repositories on older Red Hat/CentOS versions. ```shell sudo yum install -y \ jemalloc-devel \ libunwind-devel \ python-sphinx ``` -------------------------------- ### Install Optional Test Dependencies on FreeBSD Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs optional packages required to run all Varnish test cases on FreeBSD. ```shell pkg install haproxy nghttp2 vttest ``` -------------------------------- ### VCL: Append Device Type as GET Parameter Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/devicedetection.rst This VCL code appends the detected device type (from 'X-UA-Device') as a GET query parameter to the request URL. It handles both cases: when the URL already contains query parameters and when it does not, ensuring the device information is passed to the backend. ```VCL sub vcl_recv { # call some detection engine that set req.http.X-UA-Device } sub append_ua { if ((req.http.X-UA-Device) && (req.method == "GET")) { # if there are existing GET arguments; if (req.url ~ "\?") { set req.http.X-get-devicetype = "&devicetype=" + req.http.X-UA-Device; } else { set req.http.X-get-devicetype = "?devicetype=" + req.http.X-UA-Device; } set req.url = req.url + req.http.X-get-devicetype; unset req.http.X-get-devicetype; } } # do this after vcl_hash, so all Vary-ants can be purged in one go. (avoid ban()ing) sub vcl_miss { call append_ua; } sub vcl_pass { call append_ua; } # Handle redirects, otherwise standard Vary handling code from previous # examples. sub vcl_backend_response { if (bereq.http.X-UA-Device) { if (!beresp.http.Vary) { # no Vary at all set beresp.http.Vary = "X-UA-Device"; } elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device"; } # if the backend returns a redirect (think missing trailing slash), # we will potentially show the extra address to the client. we # don't want that. if the backend reorders the get parameters, you # may need to be smarter here. (? and & ordering) if (beresp.status == 301 || beresp.status == 302 || beresp.status == 303) { set beresp.http.location = regsub(beresp.http.location, "[?&]devicetype=.*$", ""); } } set beresp.http.X-UA-Device = bereq.http.X-UA-Device; } sub vcl_deliver { if ((req.http.X-UA-Device) && (resp.http.Vary)) { set resp.http.Vary = regsub(resp.http.Vary, "X-UA-Device", "User-Agent"); } } ``` -------------------------------- ### Startup CLI Command File Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/whats-new/changes-5.1.rst Demonstrates how to use the '-I cli_file' option with varnishd to execute CLI commands during startup. This is useful for loading and labeling VCL configurations. ```Shell vcl.load panic /etc/varnish_panic.vcl vcl.load siteA0 /etc/varnish_siteA.vcl vcl.load siteB0 /etc/varnish_siteB.vcl vcl.load siteC0 /etc/varnish_siteC.vcl vcl.label siteA siteA0 vcl.label siteB siteB0 vcl.label siteC siteC0 vcl.load main /etc/varnish_main.vcl vcl.use main ``` -------------------------------- ### Varnish Round-Robin Director Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/vcl-backends.rst Varnish VCL configuration demonstrating the setup of a round-robin director to distribute requests across multiple backend servers. ```VCL import directors; backend server1 { .host = "192.168.0.10"; } backend server2 { .host = "192.168.0.11"; } sub vcl_init { new bar = directors.round_robin(); bar.add_backend(server1); bar.add_backend(server2); } sub vcl_recv { # send all traffic to the bar director: set req.backend_hint = bar.backend(); } ``` -------------------------------- ### RPM Varnish Requires Example Source: https://github.com/varnishcache/varnish-cache/wiki/VIP20:-Varnish-ABI-and-packaging Illustrates the dependencies of the `varnish` package, including configuration, shared libraries, and the `varnish-libs` package itself. ```bash $ rpm -q --requires varnish | grep varnish config(varnish) = 5.1.3-2.fc26 libvarnishapi.so.1()(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.0)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.1)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.2)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.3)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.4)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.5)(64bit) libvarnishapi.so.1(LIBVARNISHAPI_1.6)(64bit) varnish-libs(x86-64) = 5.1.3-2.fc26 ``` -------------------------------- ### Varnish Startup Sequence Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/firstdesign.rst Illustrates a typical Varnish startup sequence, involving loading configuration files, switching between different configurations, and resuming operations. ```APIDOC load config /foo/bar startup_conf switch config startup_conf !mypreloadscript load config /foo/real real_conf switch config real_conf resume ``` -------------------------------- ### VCL Identifiers Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/vcl.rst VCL identifiers must start with an ASCII alphabetic character and can be followed by alphanumeric characters, hyphens, or underscores. Examples of valid and invalid identifiers are provided. ```vcl e1xam_p-le // Valid identifier 1try // Invalid identifier a%remainder // Invalid identifier ``` -------------------------------- ### Varnish Startup Configuration Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/firstdesign.rst Illustrates the process of loading and switching configuration files during Varnish startup, including custom preload scripts and real configuration loading. ```APIDOC varnish.startup load config /foo/bar startup_conf switch config startup_conf !mypreloadscript load config /foo/real real_conf switch config real_conf resume ``` -------------------------------- ### Varnish Live Traffic IRC Log Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/firstdesign.rst An IRC log detailing the initial setup and testing of Varnish with live traffic, including conversations between developers about starting the traffic flow and monitoring the system. ```APIDOC **** BEGIN LOGGING AT Thu Jul 6 12:36:48 2006 Jul 06 12:36:48 * Now talking on #varnish Jul 06 12:36:48 * EvilDES gives channel operator status to andersb Jul 06 12:36:53 * EvilDES gives channel operator status to phk Jul 06 12:36:53 hehe Jul 06 12:36:56 sånn Jul 06 12:37:00 Jepps, er dere klare? Jul 06 12:37:08 Jeg har varnish oppe og køre med leonora som backend. Jul 06 12:37:12 * EvilDES has changed the topic to: Live testing in progress! Jul 06 12:37:16 * EvilDES sets mode +t #varnish Jul 06 12:37:19 Da setter jeg på trafikk Jul 06 12:37:36 andersb: kan du starte med bare at give us trafiik i 10 sekunder eller så ? Jul 06 12:37:49 * edward (edward@f95.linpro.no) has joined #varnish Jul 06 12:38:32 hmm, først må jeg få trafikk dit. ``` -------------------------------- ### varnishtop Examples Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishtop.rst Demonstrates how to use varnishtop to display rankings of requested URLs and user agents from Varnish logs. ```bash varnishtop -i ReqURL ``` ```bash varnishtop -C -I ReqHeader:User-Agent ``` -------------------------------- ### VCL Backend Routing Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/tutorial/introduction.rst A basic VCL subroutine that routes requests to different backend servers based on the URL. It checks if the request URL starts with '/wiki' and directs it to 'wiki_server', otherwise to 'wordpress_server'. ```VCL sub vcl_recv { if (req.url ~ "^/wiki") { set req.backend_hint = wiki_server; } else { set req.backend_hint = wordpress_server; } } ``` -------------------------------- ### Varnish Workspace Initialization (Standard C) Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/cheri5.rst Illustrates the standard C implementation for initializing a Varnish workspace. This involves setting up pointers, calculating buffer boundaries, and adding a canary for overrun detection. ```C void WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { unsigned l; DSLb(DBG_WORKSPACE, "WS_Init(%s, %p, %p, %u)", id, ws, space, len); assert(space != NULL); assert(PAOK(space)); INIT_OBJ(ws, WS_MAGIC); ws->s = space; l = PRNDDN(len - 1); ws->e = ws->s + l; memset(ws->e, WS_REDZONE_END, len - l); ws->f = ws->s; assert(id[0] & 0x20); // cheesy islower() bstrcpy(ws->id, id); WS_Assert(ws); } ``` -------------------------------- ### Install Varnish via Package on OpenBSD Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_openbsd.rst Installs the Varnish Cache package on OpenBSD using the pkg_add utility. This is the recommended method for a quick and easy installation. ```shell pkg_add varnish ``` -------------------------------- ### RPM Package Provides Example Source: https://github.com/varnishcache/varnish-cache/wiki/VIP20:-Varnish-ABI-and-packaging Demonstrates how to query an RPM package for the capabilities it provides, specifically focusing on Java and pkg-config dependencies. ```bash $ rpm -q --provides java-1.8.0-openjdk | grep 'java =' java = 1.8.0 ``` ```bash $ rpm -q --provides varnish-devel | grep pkgconfig pkgconfig(varnishapi) = 5.1.3 ``` -------------------------------- ### Varnish Startup Arguments Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/firstdesign.rst Demonstrates how to pass cluster arguments to the Varnish process during startup. ```Shell varnish -c $cluster_args $other_args vs varnish $other_args ``` -------------------------------- ### CHERI Pointer Restriction Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/cheri4.rst Demonstrates CHERI's ability to restrict pointers, showing how attempting to write through a restricted pointer (ptr1) causes a core dump, while writing through an unrestricted pointer (ptr2) works fine. It also illustrates how CHERI capabilities include the start and length of memory access. ```C #include #include #include int main() { char buf[20]; char *ptr1 = cheri_perms_and(buf, CHERI_PERM_LOAD); char *ptr2 = buf; strcpy(buf, "Hello World\n"); ptr1[5] = '_'; // Will core dump ptr2[5] = '_'; // Works fine. puts(buf); return (0); } ``` -------------------------------- ### Varnish Workspace Initialization (CHERI 5/N) Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/cheri5.rst Demonstrates the Varnish workspace initialization using CHERI 5/N capabilities. CHERI simplifies the process by enforcing bounds on pointers, eliminating the need for software canaries. ```C void WS_Init(struct ws *ws, const char *id, void *space, unsigned len) { unsigned l; DSLb(DBG_WORKSPACE, "WS_Init(%s, %p, %p, %u)", id, ws, space, len); assert(space != NULL); INIT_OBJ(ws, WS_MAGIC); assert(PAOK(space)); ws->s = cheri_bounds_set(space, len); ws->e = ws->s + len ws->f = ws->s; assert(id[0] & 0x20); // cheesy islower() bstrcpy(ws->id, id); WS_Assert(ws); } ``` -------------------------------- ### Install Varnish 4 from FreeBSD Package Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_freebsd.rst Installs the Varnish 4 package on FreeBSD using the pkg command. ```bash pkg install varnish4 ``` -------------------------------- ### Varnish Cache Package Deployment with CircleCI Source: https://github.com/varnishcache/varnish-cache/wiki/Release-procedure Instructions for setting up and triggering package builds for Varnish Cache releases using Circle-CI and the pkg-varnish-cache repository. ```bash git checkout master git checkout -b x.y git push -u origin x.y ``` ```yaml .circleci/config.yml ``` ```bash jay.sh -o varnishcache -r varnish-cache -b -p dist-url: -p dist-url-sha256: ``` -------------------------------- ### VCL Compiler Import Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/patent.rst Demonstrates a VCL (Varnish Configuration Language) import statement with a long module name, as suggested by a contributor. ```text import vmod_with_impractically_long_name as v; ``` -------------------------------- ### Install Varnish from Ports on OpenBSD Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_openbsd.rst Compiles and installs Varnish Cache from the OpenBSD ports collection. This method allows for customization during the build process. ```shell cd /usr/ports/www/varnish make install ``` -------------------------------- ### Install Varnish 6 from FreeBSD Ports Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_freebsd.rst Installs Varnish 6 from the FreeBSD ports tree, allowing for custom builds or newer versions. ```bash cd /usr/ports/www/varnish6 make all install clean ``` -------------------------------- ### Executing Varnish Test Suite for Initial Assessment Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/phk/cheri1.rst This shell command sequence outlines the steps to navigate to the `varnishtest` directory and run the primary Varnish test suite. The `-i`, `-k`, and `-q` flags are used for interactive mode, keeping temporary files, and quiet output, respectively, providing an initial assessment of the CHERI-compiled Varnish's stability. ```Shell % cd bin/varnishtest % ./varnishtest -i -k -q tests/*.vtc ``` -------------------------------- ### Layering Directors in VCL for Advanced Routing Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/vcl-backends.rst This VCL example illustrates the concept of layering directors. It defines two `round_robin` directors (`dc1`, `dc2`), each managing its own set of backends. A `fallback` director (`dcprio`) is then created and configured to use `dc1` and `dc2` as its own backends, enabling complex routing logic where traffic can fall back between entire groups of servers. ```VCL import directors; sub vcl_init { new dc1 = directors.round_robin(); dc1.add_backend(server1A); dc1.add_backend(server1B); new dc2 = directors.round_robin(); dc2.add_backend(server2A); dc2.add_backend(server2B); new dcprio = directors.fallback(); dcprio.add_backend(dc1); } ``` -------------------------------- ### Varnish Backend Configuration Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/tutorial/backend_servers.rst This snippet shows a basic Varnish Configuration Language (VCL) block for defining a backend server. It specifies the host and port from which Varnish will fetch content. ```vcl vcl 4.0; backend default { .host = "www.varnish-cache.org"; .port = "80"; } ``` ```vcl vcl 4.0; backend default { .host = "127.0.0.1"; .port = "8080"; } ``` -------------------------------- ### VCL Example: Restricting Admin Access by UDS Listener Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/whats-new/upgrading-6.0.rst This VCL snippet demonstrates how to restrict access to admin-related URLs based on the UDS listener's endpoint path. It uses regex matching on `local.endpoint` to ensure that requests starting with '/admin' or '/superadmin' are only processed if they arrive on the listener whose path ends with 'admin.sock' or 'superadmin.sock' respectively. If the condition is not met, a '403 Forbidden' response is returned. ```VCL # admin requests allowed only on the listener whose path ends in # "admin.sock" if (req.url ~ "^/admin") { if (local.endpoint !~ "admin.sock$") { # wrong listener, respond with "403 Forbidden" return( synth(403) ); } else { # process the admin request ... } } # superadmin requests only allowed on the "superadmin.sock" listener if (req.url ~ "^/superadmin") { if (local.endpoint !~ "superadmin.sock$") { return( synth(403) ); } else { # superadmin request ... } } ``` -------------------------------- ### Install Varnish Cache via APT Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_debian.rst This command installs the Varnish Cache package on Debian and Ubuntu systems using the Advanced Packaging Tool (APT). Ensure your package lists are up-to-date before running this command. ```bash sudo apt-get install varnish ``` -------------------------------- ### Varnishd Command-Line Options Summary Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/whats-new/upgrading-5.1.rst Summarizes key changes and additions to varnishd command-line options for version 5.1, including new options for CLI commands at startup, VCL pre-loading, usage message printing, documentation printing, and debugging mode restrictions. ```varnish varnishd -I clifile More than one -f option permitted -b or -f required, not both, unless -d is used -? prints usage message only -x prints documentation and exits (must be only option) Only one of -F or -d can be used, not with -C -j option added 'workuser' parameter ``` -------------------------------- ### Starting Varnish Worker Process (Varnish CLI) Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/run_cli.rst This command starts the Varnish Cache worker process. It is necessary to explicitly start the child process if `varnishd` was launched with the `-d` (debugging) argument. ```Varnish CLI varnish> start ``` -------------------------------- ### Varnish CLI Command File Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishd.rst An example of a CLI command file used to load VCL configurations and set the active VCL upon Varnish startup. ```varnish-cli vcl.load panic /etc/varnish_panic.vcl vcl.load siteA0 /etc/varnish_siteA.vcl vcl.load siteB0 /etc/varnish_siteB.vcl vcl.load siteC0 /etc/varnish_siteC.vcl vcl.label siteA siteA0 vcl.label siteB siteB0 vcl.label siteC siteC0 vcl.load main /etc/varnish_main.vcl vcl.use main ``` -------------------------------- ### Install Optional Git on Debian/Ubuntu Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs Git on Debian/Ubuntu systems, optionally needed for pulling from repositories. ```shell sudo apt-get install git ``` -------------------------------- ### varnishadm Usage Examples Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishadm.rst Demonstrates various ways to use the varnishadm utility to interact with a Varnish instance, including direct command execution and piping commands. ```bash varnishadm -T localhost:999 -S /var/db/secret vcl.use foo ``` ```bash echo vcl.use foo | varnishadm -T localhost:999 -S /var/db/secret ``` ```bash echo vcl.use foo | ssh vhost varnishadm -T localhost:999 -S /var/db/secret ``` -------------------------------- ### Loading and Activating VCL Configurations via CLI Command File (Varnish CLI) Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishd.rst This snippet demonstrates a sequence of Varnish CLI commands typically placed in a file specified by the `-I` option during `varnishd` startup. It loads multiple VCL configurations, assigns labels to specific versions, and finally activates the `main` VCL configuration. Each command loads a VCL file and assigns it a name, followed by labeling and activation, ensuring the desired VCL is active upon daemon launch. ```Varnish CLI vcl.load panic /etc/varnish_panic.vcl vcl.load siteA0 /etc/varnish_siteA.vcl vcl.load siteB0 /etc/varnish_siteB.vcl vcl.load siteC0 /etc/varnish_siteC.vcl vcl.label siteA siteA0 vcl.label siteB siteB0 vcl.label siteC siteC0 vcl.load main /etc/varnish_main.vcl vcl.use main ``` -------------------------------- ### Install Optional Git on RHEL/CentOS Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs Git on Red Hat/CentOS systems, optionally needed for pulling from repositories. ```shell yum install git ``` -------------------------------- ### Install Build Dependencies on Alpine Linux Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs essential build dependencies for Varnish on Alpine Linux using apk. ```shell apk add -q \ autoconf \ automake \ build-base ``` -------------------------------- ### Varnishadm Interactive Mode Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/users-guide/run_cli.rst Demonstrates the initial output and prompt when 'varnishadm' is run without arguments, entering interactive mode. It shows the Varnish version, system information, and available commands. ```text critter phk> ./varnishadm 200 ----------------------------- Varnish Cache CLI 1.0 ----------------------------- FreeBSD,13.0-CURRENT,amd64,-jnone,-sdefault,-sdefault,-hcritbit varnish-trunk revision 2bd5d2adfc407216ebaa653fae882d3c8d47f5e1 Type 'help' for command list. Type 'quit' to close CLI session. Type 'start' to launch worker process. varnish> ``` -------------------------------- ### Varnish Test Script Example Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/varnishtest.rst An example of a varnishtest script demonstrating the simulation of a server (s1) with specific request expectations and responses, a Varnish server (v1) with VCL configuration for ESI and TTL, and a client (c1) sending requests and verifying responses. ```vcl varnishtest "#1029" server s1 { rxreq expect req.url == "/bar" txresp -gzipbody {[bar]} rxreq expect req.url == "/foo" txresp -body {

FOOBARF

} } -start varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; if (bereq.url == "/foo") { set beresp.ttl = 0s; } else { set beresp.ttl = 10m; } } } -start client c1 { txreq -url "/bar" -hdr "Accept-Encoding: gzip" rxresp gunzip expect resp.bodylen == 5 txreq -url "/foo" -hdr "Accept-Encoding: gzip" rxresp expect resp.bodylen == 21 } -run ``` -------------------------------- ### VCL Object Instantiation Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/reference/vcl.rst Demonstrates how to instantiate a VCL object using the 'new' keyword and add a backend to a director. The object name must be a valid identifier and instantiation is only available in 'vcl_init'. ```vcl sub vcl_init { new b = directors.round_robin(); b.add_backend(node1); } ``` -------------------------------- ### Install Optional Autoconf Archive on Debian/Ubuntu Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs autoconf-archive on Debian/Ubuntu, recommended for building custom Varnish modules (vmods). ```shell sudo apt-get install autoconf-archive ``` -------------------------------- ### Install Optional Graphviz for SVG on Debian/Ubuntu Source: https://github.com/varnishcache/varnish-cache/blob/master/doc/sphinx/installation/install_source.rst Installs Graphviz on Debian/Ubuntu systems, which is optionally required for rebuilding SVG files. ```shell sudo apt-get install graphviz ``` -------------------------------- ### Prepare Release Branch and Update Documentation Source: https://github.com/varnishcache/varnish-cache/wiki/Release-procedure Steps to prepare for a new release by checking out the release branch, updating documentation files like 'changes.rst' and 'index.rst', and ensuring syntax correctness. ```git git checkout x.y ``` ```bash rst2html --halt=2 doc/changes.rst >> /dev/null ```