You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See [older versions](https://github.com/eea/eea.docker.varnish/releases)
25
25
@@ -41,57 +41,20 @@ See [older versions](https://github.com/eea/eea.docker.varnish/releases)
41
41
1. Install [Docker](https://www.docker.com/).
42
42
43
43
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
+
44
53
## Usage
45
54
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`
94
56
57
+
See [docker-compose.yml](https://github.com/eea/eea.docker.varnish/blob/7.x/docker-compose.yml).
95
58
96
59
### Extend the image with a custom varnish.vcl file
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
118
78
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"
123
80
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
125
82
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>";
128
84
129
-
### Change and reload configuration without restarting the container
85
+
4. Add description in `Readme.md`
130
86
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
135
88
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.
137
90
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>);
143
92
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.
150
93
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:
153
95
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
*`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
0 commit comments