File: backend_servers.rst

package info (click to toggle)
varnish 7.7.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,256 kB
  • sloc: ansic: 104,222; python: 2,679; makefile: 1,303; sh: 1,077; awk: 114; perl: 105; ruby: 41
file content (55 lines) | stat: -rw-r--r-- 1,665 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
..
	Copyright (c) 2010-2015 Varnish Software AS
	SPDX-License-Identifier: BSD-2-Clause
	See LICENSE file for full text of license

.. _tutorial-backend_servers:

Backend servers
---------------

Varnish has a concept of `backend` or origin servers. A backend
server is the server providing the content Varnish will accelerate via the cache.

Our first task is to tell Varnish where it can find its content. Start
your favorite text editor and open the Varnish default configuration
file. If you installed from source this is
`/usr/local/etc/varnish/default.vcl`, if you installed from a package it
is probably `/etc/varnish/default.vcl`.

If you've been following the tutorial there is probably a section of
the configuration that looks like this::

  vcl 4.0;

  backend default {
      .host = "www.varnish-cache.org";
      .port = "80";
  }

This means we set up a backend in Varnish that fetches content from
the host www.varnish-cache.org on port 80.

Since you probably don't want to be mirroring varnish-cache.org we
need to get Varnish to fetch content from your own origin
server. We've already bound Varnish to the public port 80 on the
server so now we need to tie it to the origin.

For this example, let's pretend the origin server is running on
localhost, port 8080.::

  vcl 4.0;

  backend default {
    .host = "127.0.0.1";
    .port = "8080";
  }


Varnish can have several backends defined and can even join several backends
together into clusters of backends for load balancing purposes, having Varnish
pick one backend based on different algorithms.

Next, let's have a look at some of what makes Varnish unique and what you can do with it.