Difference between revisions of "Varnish"

From ArchWiki
Jump to: navigation, search
m (Multiple backends: updated for systemd)
Line 4: Line 4:
 
== Multiple backends ==
 
== Multiple backends ==
  
By default, varnish comes configured in {{ic|/etc/conf.d/varnish}} to use '''localhost:8080''' as the only backend:
+
By default, varnish comes configured in {{ic|/usr/lib/systemd/system/varnish.service}} to use '''localhost:8080''' as the only backend:
  
{{hc|/etc/conf.d/varnish|
+
{{hc|/usr/lib/systemd/system/varnish.service|
VARNISHD_OPTS="-a 0.0.0.0:80 \
+
[Unit]
              -b localhost:8080 \
+
Description=Web Application Accelerator
              -T localhost:6082 \
+
After=network.target
              -s malloc,64M
+
 
              -u nobody -g nobody"
+
[Service]
 +
ExecStart=/usr/bin/varnishd -a 0.0.0.0:80 -f /etc/varnish/default.vcl -T localhost:6082 -s malloc,64M -u nobody -g nobody -F
 +
ExecReload=/usr/bin/varnish-vcl-reload
 +
 
 +
[Install]
 +
WantedBy=multi-user.target}}
  
VARNISH_CFG="/etc/varnish/default.vcl"}}
 
  
 
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, 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:
  
{{bc|$ /etc/rc.d/varnish reload}}
+
{{bc|$ systemctl restart varnish.service}}
  
 
=== Manual VCL load ===
 
=== Manual VCL load ===

Revision as of 02:16, 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 /usr/lib/systemd/system/varnish.service to use localhost:8080 as the only backend:

/usr/lib/systemd/system/varnish.service
Template error: are you trying to use the = sign? Visit Help:Template#Escape template-breaking characters for workarounds.


Also, the 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 /etc/varnish/default.vcl with at least one backend and call:

$ 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