Skip to content

Commit cc85dae

Browse files
authored
refactor: update README.md, add --varnish-docker-image flag (#36)
1 parent 7c7852b commit cc85dae

File tree

2 files changed

+45
-32
lines changed

2 files changed

+45
-32
lines changed

README.md

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
1-
[![tests](https://github.com/ddev/ddev-varnish/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-varnish/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2025.svg)
1+
[![add-on registry](https://img.shields.io/badge/DDEV-Add--on_Registry-blue)](https://addons.ddev.com)
2+
[![tests](https://github.com/ddev/ddev-varnish/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/ddev/ddev-varnish/actions/workflows/tests.yml?query=branch%3Amain)
3+
[![last commit](https://img.shields.io/github/last-commit/ddev/ddev-varnish)](https://github.com/ddev/ddev-varnish/commits)
4+
[![release](https://img.shields.io/github/v/release/ddev/ddev-varnish)](https://github.com/ddev/ddev-varnish/releases/latest)
25

3-
# ddev-varnish
6+
# DDEV Adminer
47

5-
This repository allows you to quickly install the Varnish reverse proxy into a [DDEV](https://ddev.readthedocs.io) project using the instructions below.
8+
## Overview
69

7-
## Installation
8-
9-
For DDEV v1.23.5 or above run
10-
11-
```sh
12-
ddev add-on get ddev/ddev-varnish
13-
```
10+
[Varnish Cache](https://varnish-cache.org/) 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. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture.
1411

15-
For earlier versions of DDEV run
12+
This add-on integrates Varnish into your [DDEV](https://ddev.com/) project.
1613

17-
```sh
18-
ddev get ddev/ddev-varnish
19-
```
20-
21-
Then restart your project
14+
## Installation
2215

23-
```sh
16+
```bash
17+
ddev add-on get ddev/ddev-varnish
2418
ddev restart
2519
```
2620

2721
> [!NOTE]
28-
> If you change `additional_hostnames` or `additional_fqdns`, you have to re-run `ddev add-on get ddev/ddev-varnish`
22+
> Run `ddev add-on get ddev/ddev-varnish` after changes to `name`, `additional_hostnames`, `additional_fqdns`, or `project_tld` in `.ddev/config.yaml` so that `.ddev/docker-compose.varnish_extras.yaml` is regenerated.
2923
30-
## Explanation
24+
After installation, make sure to commit the `.ddev` directory to version control.
3125

32-
The Varnish service inserts itself between ddev-router and the web container, so that calls
33-
to the web container are routed through Varnish first. The [docker-compose.varnish.yaml](docker-compose.varnish.yaml)
34-
installs Varnish and uses the default domain as its own host name. A `docker-compose.varnish_extras.yaml` file is generated on install which replaces the `VIRTUAL_HOST` variable of the web container with a sub-domain of the website URL. For example, `mysite.ddev.site`, would be accessible via Varnish on `mysite.ddev.site` and directly on `novarnish.mysite.ddev.site`.
26+
## Usage
3527

36-
If you use a `project_tld` other than `ddev.site` or `additional_fqdns` DDEV will help add hosts entries for the hostnames automagically; however, you'll need to add entries for the `novarnish.*` sub-domains yourself, e.g. `ddev hostname novarnish.testaddfqdn.random.tld 127.0.0.1`.
28+
The Varnish service inserts itself between ddev-router and the web container, so that calls to the web container are routed through Varnish first. The [docker-compose.varnish.yaml](docker-compose.varnish.yaml) installs Varnish and uses the default domain as its own host name.
3729

38-
Run `ddev add-on get ddev/ddev-varnish` after changes to `name`, `additional_hostnames`, `additional_fqdns`, or `project_tld` in `.ddev/config.yaml` so that `.ddev/docker-compose.varnish_extras.yaml` is regenerated.
30+
A `docker-compose.varnish_extras.yaml` file is generated on install which replaces the `VIRTUAL_HOST` variable of the web container with a sub-domain of the website URL. For example, `mysite.ddev.site`, would be accessible via Varnish on `mysite.ddev.site` and directly on `novarnish.mysite.ddev.site`.
3931

40-
## Helper commands
32+
If you use a `project_tld` other than `ddev.site` or `additional_fqdns` DDEV will help add hosts entries for the hostnames automagically; however, you'll need to add entries for the `novarnish.*` sub-domains yourself, e.g. `ddev hostname novarnish.testaddfqdn.random.tld 127.0.0.1`.
4133

42-
This addon also providers several helper commands. These helpers allow developers to run Varnish commands from the host, however, the commands are actually run inside the Varnish container.
34+
## Helper Commands
35+
36+
This add-on also providers several helper commands. These helpers allow developers to run Varnish commands from the host, however, the commands are actually run inside the Varnish container.
4337

4438
| Command | Description |
4539
| --- | --- |
@@ -51,13 +45,32 @@ This addon also providers several helper commands. These helpers allow developer
5145
| `ddev varnishstat` | Display Varnish Cache statistics |
5246
| `ddev varnishtest` | Test program for Varnish |
5347
| `ddev varnishtop` | Display Varnish log entry ranking |
48+
| `ddev logs -s varnish` | Check Varnish logs |
49+
50+
See [The Varnish Reference Manual](https://varnish-cache.org/docs/6.0/reference/index.html) for more information about the commands, their flags, and their arguments.
51+
52+
## Advanced Customization
53+
54+
You may want to edit the `.ddev/varnish/default.vcl` to meet your needs. Remember to remove `#ddev-generated` from the file if you want your changes to the file preserved.
55+
56+
To change the Docker image:
57+
58+
```bash
59+
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:6.0
60+
ddev add-on get ddev/ddev-varnish
61+
ddev restart
62+
```
63+
64+
Make sure to commit the `.ddev/.env.varnish` file to version control.
5465

55-
See [The Varnish Reference Manual](https://varnish-cache.org/docs/6.5/reference/index.html) for more information about the commands, their flags, and their arguments.
66+
All customization options (use with caution):
5667

57-
## Additional Configuration
68+
| Variable | Flag | Default |
69+
| -------- | ---- | ------- |
70+
| `VARNISH_DOCKER_IMAGE` | `--varnish-docker-image` | `varnish:6.0` |
5871

59-
* You may want to edit the `.ddev/varnish/default.vcl` to meet your needs. Remember to remove `#ddev-generated` from the file if you want your changes to the file preserved.
72+
## Credits
6073

61-
**Maintained by [@jedubois](https://github.com/jedubois) and [@rfay](https://github.com/rfay)**
74+
**Maintained by [@jedubois](https://github.com/jedubois) and the [DDEV team](https://ddev.com/support-ddev/)**
6275

6376
**Based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/varnish) pioneered by [rikwillems](https://github.com/rikwillems)**

docker-compose.varnish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
services:
33
varnish:
44
container_name: ddev-${DDEV_SITENAME}-varnish
5-
image: varnish:6.0
5+
image: ${VARNISH_DOCKER_IMAGE:-varnish:6.0}
66
# These labels ensure this service is discoverable by ddev.
77
labels:
88
com.ddev.site-name: ${DDEV_SITENAME}
@@ -24,7 +24,7 @@ services:
2424
- ".:/mnt/ddev_config"
2525
depends_on:
2626
- web
27-
# Add mailhog support
27+
# Add mailpit support
2828
expose:
2929
- "8025"
3030
entrypoint:

0 commit comments

Comments
 (0)