Difference between revisions of "Varnish"

From ArchWiki
Jump to: navigation, search
(Multiple backends: added some more info about configuration)
m (Multiple backends: changed wording on when a config reload is necessary)
Line 27: Line 27:
{{bc|$ cp '/usr/lib/systemd/system/varnish.service' '/etc/systemd/system/multi-user.target.wants/varnish.service'}}
{{bc|$ cp '/usr/lib/systemd/system/varnish.service' '/etc/systemd/system/multi-user.target.wants/varnish.service'}}
Also, the {{ic|VARNISH_CFG}} file is not loaded on varnish instalation nor service startup. So in case you want multiple backends from a VCL file, you need to edit {{ic|/etc/varnish/default.vcl}} with at least one backend and call:
Also, if you change the config file {{ic|/etc/varnish/default.vcl}} you'll need to reload varnish:
{{bc|$ systemctl reload varnish.service}}
or restart
{{bc|$ systemctl restart varnish.service}}
{{bc|$ systemctl restart varnish.service}}
or to reload
{{bc|$ systemctl reload varnish.service}}
=== Manual VCL load ===
=== Manual VCL load ===

Revision as of 02:32, 11 June 2013

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents.

Multiple backends

By default, varnish comes configured in /etc/varnish/default.vcl to use localhost:8080 as the only backend, default.vcl is called by the default systemd varnish.service file :

Description=Web Application Accelerator

ExecStart=/usr/bin/varnishd -a -f /etc/varnish/default.vcl -T localhost:6082 -s malloc,64M -u nobody -g nobody -F


systemctl enable merely makes a symlink to the default

$ systemctl enable varnish
ln -s '/usr/lib/systemd/system/varnish.service' '/etc/systemd/system/multi-user.target.wants/varnish.service'

instead copy it and edit to increase malloc default.vcl etc:

$ cp '/usr/lib/systemd/system/varnish.service' '/etc/systemd/system/multi-user.target.wants/varnish.service'

Also, if you change the config file /etc/varnish/default.vcl you'll need to reload varnish:

$ systemctl reload varnish.service

or restart

$ systemctl restart varnish.service

Manual VCL load

If the previous VCL configuration reload failed, try loading the VCL file manually:

  1. Connect to the varnish console:
    $ varnishadm -T localhost:6082
  2. Load the default VCL. Make sure it has at least one backend:
    varnish> vcl.load default /etc/varnish/default.vcl
  3. Make it active:
    varnish> vcl.use default
  4. Start the child proccess (optional):
    varnish> start