Skip to content

Commit 97147da

Browse files
author
valentinab25
committed
Update documentation
1 parent ad65a64 commit 97147da

3 files changed

Lines changed: 50 additions & 152 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2022-03-09 (7.2-1.0)
4+
5+
- Upgrade to varnish 7.2
6+
- Remove unused scripts, as varnish is integrated with Rancher DNS and does not need them
7+
38
## 2020-07-27 (4.1-6.5)
49

510
- Add `BACKENDS_PURGE_LIST` variable #18

Readme.md

Lines changed: 30 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ and reload.
66
This image is generic, thus you can obviously re-use it within
77
your non-related EEA projects.
88

9-
- Debian Stretch
10-
- Varnish **4.1.11**
11-
- Varnish agent 2 **4.1.4**
12-
- Varnish dashboard
9+
- Alpine 3.15
10+
- Varnish **7.2**
1311
- EXPOSE **6081 6085**
1412

1513
## Supported tags and respective Dockerfile links
1614

17-
- `:latest` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/blob/master/varnish/Dockerfile) (Debian Stretch, Varnish 4.1)
15+
- `:latest` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/blob/7.x/Dockerfile) (Debian Stretch, Varnish 7.2)
1816

1917
### Stable and immutable tags
2018

21-
- `:4.1-6.4` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/tree/4.1-6.4/varnish/Dockerfile) - Varnish: **4.1.11** Release: **6.4
22-
- `:4.1-6.5` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/tree/4.1-6.5/varnish/Dockerfile) - Varnish: **4.1.11** Release: **6.5
19+
- `:4.1-6.5` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/tree/4.1-6.5/varnish/Dockerfile) - Varnish: **4.1.11** Release: **6.5**
20+
- `:7.2-1.0` [*Dockerfile*](https://github.com/eea/eea.docker.varnish/tree/7.2-1.0/Dockerfile) - Varnish: **7.2** Release: **1.0**
21+
22+
2323

2424
See [older versions](https://github.com/eea/eea.docker.varnish/releases)
2525

@@ -41,57 +41,20 @@ See [older versions](https://github.com/eea/eea.docker.varnish/releases)
4141
1. Install [Docker](https://www.docker.com/).
4242

4343

44+
## Variables
45+
46+
* `VARNISH_HTTP_PORT` - varnish port
47+
* `VARNISH_HTTPS_PORT` - varnish ssl port
48+
* `VARNISH_SIZE` - varnish cache size
49+
* `AUTOKILL_CRON` - Varnish re-create crontab, will force a recreation of the container. Uses UTC time, format is linux crontab - for example - `0 2 * * *` is 02:00 UTC each day"
50+
* `VARNISH_CFG_CONTENT` - Multiline variable that will be written in the `default.vcl` file
51+
52+
4453
## Usage
4554

46-
### Run with Docker Compose
47-
48-
Here is a basic example of a `docker-compose.yml` file using the `eeacms/varnish` docker image:
49-
50-
version: "2"
51-
services:
52-
varnish:
53-
image: eeacms/varnish
54-
ports:
55-
- "80:6081"
56-
- "6085:6085"
57-
depends_on:
58-
- anon
59-
- auth
60-
- download
61-
environment:
62-
BACKENDS: "anon auth download"
63-
BACKENDS_PORT: "8080"
64-
DNS_ENABLED: "true"
65-
BACKENDS_PROBE_INTERVAL: "3s"
66-
BACKENDS_PROBE_TIMEOUT: "1s"
67-
BACKENDS_PROBE_WINDOW: "3"
68-
BACKENDS_PROBE_THRESHOLD: "2"
69-
DASHBOARD_USER: "admin"
70-
DASHBOARD_PASSWORD: "admin"
71-
DASHBOARD_SERVERS: "varnish"
72-
DASHBOARD_DNS_ENABLED: "true"
73-
anon:
74-
image: eeacms/hello
75-
environment:
76-
PORT: "8080"
77-
auth:
78-
image: eeacms/hello
79-
environment:
80-
PORT: "8080"
81-
download:
82-
image: eeacms/hello
83-
environment:
84-
PORT: "8080"
85-
86-
87-
The application can be scaled to use more server instances as backends, with `docker-compose scale`:
88-
89-
$ docker-compose up -d
90-
$ docker-compose scale anon=4 auth=2 varnish=2
91-
92-
An example of a more complex application using the `eeacms/varnish` with `docker-compose`
93-
image is [EEA WWW](https://github.com/eea/eea.docker.www).
55+
### Using `VARNISH_CFG_CONTENT`
9456

57+
See [docker-compose.yml](https://github.com/eea/eea.docker.varnish/blob/7.x/docker-compose.yml).
9558

9659
### Extend the image with a custom varnish.vcl file
9760

@@ -107,91 +70,35 @@ and then run
10770

10871
$ docker build -t varnish-custom /path/to/Dockerfile
10972

110-
### Support for specifying probe request headers
73+
## How to add docker environment variables in varnish.vcl
11174

112-
Two environment variables support defining specific probe request headers.
113-
The primary warning / tricky part is around the delimiter used for separating
114-
the individual headers. Below is an example:
75+
1. Choose relevant variable name, starting with `VARNISH_` - eg. `VARNISH_EXAMPLE`
11576

116-
BACKENDS_PROBE_REQUEST: 'GET / HTTP/1.1|Host: example.com|Connection: close|User-Agent: Varnish Health Probe'
117-
BACKENDS_PROBE_REQUEST_DELIMITER: '|'
77+
2. Add default value in Dockerfile
11878

119-
The above will result in the probe being specified using the probe.request attribute
120-
and will replace the default probe.url attribute completely.
121-
The important point, of course, is that you need to pick an appropriate delimiter
122-
that is not contained within any headers that you wish to pass.
79+
ENV VARNISH_EXAMPLE="GET"
12380

124-
The hostname of the current backend being probed can be specify using the `%(hostname)s` placeholder:
81+
3. Add variable in `<>` in varnish.vcl
12582

126-
BACKENDS_PROBE_REQUEST: 'GET / HTTP/1.1|Host: %(hostname)s|Connection: close|User-Agent: Varnish Health Probe'
127-
BACKENDS_PROBE_REQUEST_DELIMITER: '|'
83+
set req.http.X-Varnish-Routed = "<VARNISH_EXAMPLE>";
12884

129-
### Change and reload configuration without restarting the container
85+
4. Add description in `Readme.md`
13086

131-
If the configuration directory is mounted as a volume, you can modify
132-
it from outside the container. In order for the modifications
133-
to be loaded by the varnish daemon, you have to run the `reload` command,
134-
as following:
87+
### Rancher integration
13588

136-
$ docker exec <container-name-or-id> reload
89+
Use `dynamic.director` to integrate varnish in rancher DNS - if a backend containers are changed, it knows to get the latest list of IPs automatically.
13790

138-
The command will load the new configuration, compile it, and if compilation
139-
succeeds replace the old one with it. If compilation of the new configuration
140-
fails, the varnish daemon will continue to use the old configuration.
141-
Keep in mind that the only way to restore a previous configuration is to
142-
restore the configuration files and then reload them.
91+
new cluster = dynamic.director(port = "<VARNISH_BACKEND_PORT>", ttl = <VARNISH_DNS_TTL>);
14392

144-
### Support for stripping cookies for better caching
145-
By default, if any cookies are present, the cache is bypassed. This section describes
146-
new support for configuration of various cookie-based cache options. Configuration is
147-
enabled with the COOKIES environment variable. If set, additional code
148-
is executed that builds a cookie_config.vcl file containing additions to
149-
the generated default.vcl file. The following cookie options are currently supported.
15093

151-
1. Whitelist of cookies - Allows stripping all but a small list of cookies
152-
2. (Future) Remove cookies for listed static file types, so caching works
94+
### Example:
15395

154-
#### Whitelist of cookies
155-
With this option you provide a regular expression describing those cookies that should
156-
be passed through to the backend. All cookies not described by the expression will be
157-
stripped from the headers. Here is an example.
158-
```
159-
COOKIES=true
160-
COOKIES_WHITELIST=(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)
161-
```
96+
You can use plone-varnish as an example of usage.
16297

16398
### Upgrade
16499

165100
$ docker pull eeacms/varnish
166101

167-
## Supported environment variables ##
168-
169-
170-
As varnish has close to no purpose by itself, this image should be used
171-
in combination with others with [Docker Compose](https://docs.docker.com/compose/).
172-
The varnish daemon can be configured by modifying the following environment variables:
173-
174-
* `CACHE_SIZE` Size of the RAM cache storage (default `2G`)
175-
* `ADDRESS_PORT` HTTP listen address and port (default `:6081`)
176-
* `ADMIN_PORT` HTTP admin address and port (e.g. `:6082`)
177-
* `BACKENDS` A list of `host[:port]` pairs separated by space
178-
(e.g. `BACKENDS="127.0.0.1 74.125.140.103:8080"`)
179-
* `BACKENDS_PORT` Default port to be used for backends (defalut `80`)
180-
* `BACKENDS_PROBE_ENABLED` Enable backend probe (default `True`)
181-
* `BACKENDS_PROBE_URL` Backend probe URL (default `/`)
182-
* `BACKENDS_PROBE_TIMEOUT` Backend probe timeout (defalut `1s`)
183-
* `BACKENDS_PROBE_INTERVAL` Backend probe interval (defalut `1s`)
184-
* `BACKENDS_PROBE_WINDOW` Backend probe window (defalut `3`)
185-
* `BACKENDS_PROBE_THRESHOLD` Backend probe threshold (defalut `2`)
186-
* `BACKENDS_SAINT_MODE` Register backends using [saintmode module](https://github.com/varnish/varnish-modules/blob/master/docs/saintmode.rst)
187-
* `BACKENDS_PROBE_REQUEST` Backend probe request header list (default empty)
188-
* `BACKENDS_PROBE_REQUEST_DELIMITER` Backend probe request headers delimiter (default `|`)
189-
* `BACKENDS_PURGE_LIST` Backend ip/ip range ';' separated list to use in the purge acl, defaults to `localhost;172.17.0.0/16;10.42.0.0/16`
190-
* `COOKIES` Enables cookie configuration
191-
* `COOKIES_WHITELIST` A regular expression describing cookies that are passed through, all others are stripped
192-
* `AUTOKILL_CRON` Has to be used with healtchecks enabled on varnish ports, it will kill the varnish cache process ( which exposes the ports ) keeping the container running, uses Linux Crontab format `[Minute] [hour] [Day_of_the_Month] [Month_of_the_Year] [Day_of_the_Week]`, UTC time
193-
* `VARNISH_SINGLE_CLUSTER`
194-
* `VARNISH_CLUSTER`
195102

196103
## Copyright and license
197104

docker-compose.yml

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
version: "2"
22
services:
33
varnish:
4-
image: eeacms/varnish
4+
image: eeacms/varnish:7
55
ports:
6-
- "80:6081"
7-
- "6085:6085"
6+
- "8080:8080"
7+
- "8443:8443"
88
depends_on:
9-
- anon
10-
- auth
11-
- download
9+
- hello
1210
environment:
13-
COOKIES: "true"
14-
COOKIES_WHITELIST: "(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)"
15-
BACKENDS: "anon auth download"
16-
BACKENDS_PORT: "8080"
17-
DNS_ENABLED: "true"
18-
BACKENDS_PROBE_INTERVAL: "3s"
19-
BACKENDS_PROBE_TIMEOUT: "1s"
20-
BACKENDS_PROBE_WINDOW: "3"
21-
BACKENDS_PROBE_THRESHOLD: "2"
22-
DASHBOARD_USER: "admin"
23-
DASHBOARD_PASSWORD: "admin"
24-
DASHBOARD_SERVERS: "varnish"
25-
DASHBOARD_DNS_ENABLED: "true"
26-
anon:
11+
VARNISH_HTTP_PORT: 8080
12+
VARNISH_CFG_CONTENT: |-
13+
vcl 4.1;
14+
15+
backend default {
16+
.host = "hello";
17+
.port = "80";
18+
}
19+
20+
hello:
2721
image: eeacms/hello
2822
environment:
29-
PORT: "8080"
30-
auth:
31-
image: eeacms/hello
32-
environment:
33-
PORT: "8080"
34-
download:
35-
image: eeacms/hello
36-
environment:
37-
PORT: "8080"
23+
PORT: "80"

0 commit comments

Comments
 (0)