1 # Using a Varnish Cache
3 Varnish is a layer that sits between your web server and your backend application -
4 it does something similar to nginx caching, but tends to be optimised for speed over
7 To set up a varnish cache, first you'll need to install varnish.
9 This will vary by distribution, and since this is a rather advanced guide,
10 no copy-paste instructions are provided. It's probably in your distribution's
11 package manager, though. `apt-get install varnish` and so on.
13 Once you have varnish installed, you'll need to configure it to work with akkoma.
15 Copy the configuration file to the varnish configuration directory:
17 cp installation/akkoma.vcl /etc/varnish/akkoma.vcl
19 You may want to check if varnish added a `default.vcl` file to the same directory,
20 if so you can just remove it without issue.
22 Then boot up varnish, probably `systemctl start varnish` or `service varnish start`.
24 Now you should be able to `curl -D- localhost:6081` and see a bunch of
27 Once that's out of the way, we can point our webserver at varnish. This
32 server 127.0.0.1:6081 max_fails=5 fail_timeout=60s;
38 reverse_proxy 127.0.0.1:6081
40 Now hopefully it all works
42 If you get a HTTPS redirect loop, you may need to remove this part of the VCL
45 if (std.port(server.ip) != 443) {
46 set req.http.X-Forwarded-Proto = "http";
47 set req.http.x-redir = "https://" + req.http.host + req.url;
48 return (synth(750, ""));
50 set req.http.X-Forwarded-Proto = "https";
54 This will allow your webserver alone to handle redirects.