Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f758551
Automated commit by Keepalive Workflow to keep the repository active
May 20, 2023
f244418
Only do keepalive on stable
rfay May 20, 2023
274f104
Fix HEAD breakage with omit-container=dba being gone (#22)
rfay Jun 27, 2023
7313ed5
Automated commit by Keepalive Workflow to keep the repository active
Aug 16, 2023
123ec2e
Automated commit by Keepalive Workflow to keep the repository active
Oct 5, 2023
d2d1fb5
Automated commit by Keepalive Workflow to keep the repository active
Nov 24, 2023
8602ef8
Automated commit by Keepalive Workflow to keep the repository active
Jan 13, 2024
9291d35
Automated commit by Keepalive Workflow to keep the repository active
Mar 3, 2024
3465fc7
Use official DDEV workflow action (#26)
tyler36 Mar 14, 2024
0eaf987
chore(*): Automated commit to keep the repository active
May 8, 2024
ecb0113
⏫ bump github-action-add-on (#27)
tyler36 Jun 10, 2024
a3ee718
fix: remove empty lines from docker-compose.varnish_extras.yaml, fixe…
stasadev Aug 2, 2024
9b7ee3a
docs: update `ddev get` to `ddev add-on get` in readme (#29)
ChloeSartorelli Oct 24, 2024
053aa16
fix: make extra docker-compose always have correct primary hostname, …
FlorentTorregrosa Dec 26, 2024
2c492ce
fix: use dynamic ports for router and mailpit, fixes #23 (#30)
zeshanziya Jan 21, 2025
8555209
feat: update setup for 2025 (#31)
stasadev Jan 21, 2025
fd04fad
feat: add issue and PR templates (#33)
stasadev Apr 10, 2025
41f7a66
refactor: use `#!/usr/bin/env bash` instead of `#!/bin/bash` (#34)
stasadev Apr 17, 2025
7c7852b
test: update tests, add version constraint v1.24.3 (#35)
stasadev Apr 17, 2025
cc85dae
refactor: update README.md, add `--varnish-docker-image` flag (#36)
stasadev Apr 17, 2025
32ee3a5
fix: copy-paste mistake (#37)
stasadev Apr 17, 2025
59ea68e
feat: Provide environment variable to customize varnishd startup para…
das-peter Jul 22, 2025
cfeeb53
feat: Provide command to reload config in place, fixes #44 (#45)
das-peter Aug 5, 2025
2375b93
feat: use Varnish only for `web:80`, remove novarnish subdomains, fix…
stasadev Nov 19, 2025
d0c864e
chore(*): run update checker, version constraint v1.24.10 (#47)
stasadev Nov 19, 2025
174f6cd
feat: use bash for `ddev ssh -s varnish` (#48)
stasadev Nov 19, 2025
8506cb4
feat: restore novarnish.* subdomains via VCL pipe mode, for #46 (#49)
stasadev May 1, 2026
f534447
chore: run `ddev utility addon-update-checker` (#50)
stasadev May 1, 2026
7564b10
test: fix mailpit assertions caused by upstream changes (#51)
stasadev May 28, 2026
a46415d
Merge remote-tracking branch 'source/main' into merge-src
reithor Jun 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{bats,sh,yml,yaml}]
indent_size = 2
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Exclude files from releases/tarballs
tests/ export-ignore
.github/ export-ignore
.gitattributes export-ignore
.editorconfig export-ignore
45 changes: 45 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 🐞 Bug report or Support Request
description: Create a report to help us improve.
labels: [bug]
body:
- type: checkboxes
attributes:
label: Preliminary checklist
description: Please complete the following checks before submitting an issue.
options:
- label: I am using the latest stable version of DDEV
required: true
- label: I am using the latest stable version of this add-on
required: true
- type: textarea
attributes:
label: Expected Behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
attributes:
label: Actual Behavior
description: What actually happened instead?
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Specific steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run `...`
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Screenshots? Anything that will give us more context about your issue!

💡 Attach images or log files by clicking this area to highlight it and dragging files in.
validations:
required: false
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 🚀 Feature request
description: Suggest an idea for this project.
labels: [enhancement]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search existing issues to see if one already exists for your request.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Is your feature request related to a problem?
description: Clearly and concisely describe the problem. (Ex. I'm always frustrated when...)
validations:
required: true
- type: textarea
attributes:
label: Describe your solution
description: Clearly and concisely describe what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives
description: Clearly and concisely describe any alternative solutions or features you've considered.
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request.
validations:
required: false
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## The Issue

- Fixes #REPLACE_ME_WITH_RELATED_ISSUE_NUMBER

<!-- Provide a brief description of the issue. -->

## How This PR Solves The Issue

<!-- Describe the key change(s) in this PR that address the issue above. -->

## Manual Testing Instructions

<!-- If this PR changes logic, consider adding additional steps or context to the instructions below. -->

```bash
ddev add-on get https://github.com/ddev/ddev-varnish/tarball/refs/pull/REPLACE_ME_WITH_THIS_PR_NUMBER/head
ddev restart
```

## Automated Testing Overview

<!-- Please describe the tests introduced by this PR, or explain why no tests are needed. -->

## Release/Deployment Notes

<!-- Does this affect anything else or have ramifications for other code? Does anything have to be done on deployment? -->
85 changes: 21 additions & 64 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,45 @@
name: tests
on:
pull_request:
paths-ignore:
- "**.md"
push:
branches: [ main ]
paths-ignore:
- "**.md"

schedule:
- cron: '32 07 * * *'
- cron: '25 08 * * *'

workflow_dispatch:
inputs:
debug_enabled:
description: 'Debug with tmate set "debug_enabled"'
type: boolean
description: Debug with tmate
required: false
default: "false"
default: false

defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
NIGHTLY_DDEV_PR_URL: "https://nightly.link/ddev/ddev/actions/runs/1720215802/ddev-linux-amd64.zip"
# Allow ddev get to use a github token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Allow `--HEAD` flag when running tests against HEAD
HOMEBREW_NO_INSTALL_FROM_API: 1
permissions:
contents: read

jobs:
tests:
defaults:
run:
shell: bash

strategy:
matrix:
ddev_version: [stable, HEAD]
# ddev_version: [stable, edge, HEAD, PR]
fail-fast: false

runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Environment setup
run: |
brew install bats-core mkcert
mkcert -install

- name: Use ddev stable
if: matrix.ddev_version == 'stable'
run: brew install ddev/ddev/ddev

- name: Use ddev edge
if: matrix.ddev_version == 'edge'
run: brew install ddev/ddev-edge/ddev

- name: Use ddev HEAD
if: matrix.ddev_version == 'HEAD'
run: brew install --HEAD ddev/ddev/ddev

- name: Use ddev PR
if: matrix.ddev_version == 'PR'
run: |
curl -sSL -o ddev_linux.zip ${NIGHTLY_DDEV_PR_URL}
unzip ddev_linux.zip
mv ddev /usr/local/bin/ddev && chmod +x /usr/local/bin/ddev

- name: Download docker images
run: |
mkdir junk && pushd junk && ddev config --omit-containers=dba,db && ddev debug download-images >/dev/null
- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}

- name: tests
run: bats tests

# keepalive-workflow adds a dummy commit if there's no other action here, keeps
# GitHub from turning off tests after 60 days
- uses: gautamkrishnar/keepalive-workflow@v1
- uses: ddev/github-action-add-on-test@v2
with:
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: ${{ github.event.inputs.debug_enabled }}
addon_repository: ${{ env.GITHUB_REPOSITORY }}
addon_ref: ${{ env.GITHUB_REF }}
106 changes: 79 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,97 @@
[![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/2024.svg)
[![add-on registry](https://img.shields.io/badge/DDEV-Add--on_Registry-blue)](https://addons.ddev.com)
[![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)
[![last commit](https://img.shields.io/github/last-commit/ddev/ddev-varnish)](https://github.com/ddev/ddev-varnish/commits)
[![release](https://img.shields.io/github/v/release/ddev/ddev-varnish)](https://github.com/ddev/ddev-varnish/releases/latest)

# ddev-varnish
# DDEV Varnish

This repository allows you to quickly install the Varnish reverse proxy into a [DDEV](https://ddev.readthedocs.io) project using just `ddev get ddev/ddev-varnish`.
## Overview

[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.

This add-on integrates Varnish into your [DDEV](https://ddev.com/) project.

## Installation

1. `ddev get ddev/ddev-varnish`
2. `ddev restart`
```bash
ddev add-on get ddev/ddev-varnish
ddev restart
```

> [!NOTE]
> Run `ddev add-on get ddev/ddev-varnish` after changes in `name`, `additional_hostnames`, `additional_fqdns`, `project_tld`, the Mailpit ports, or `web_extra_exposed_ports` in `.ddev/config.yaml` so that `.ddev/docker-compose.varnish_extras.yaml` is regenerated.

After installation, make sure to commit the `.ddev` directory to version control.

## Usage

The Varnish service inserts itself between ddev-router and the web container for port 80/443 only. Mailpit and `web_extra_exposed_ports` continue to route directly to the web container, bypassing Varnish.

A `docker-compose.varnish_extras.yaml` file is generated on install which:

- Removes port 80 from the web container's `HTTP_EXPOSE` and `HTTPS_EXPOSE` so Varnish owns that traffic.
- Extends the Varnish container's `VIRTUAL_HOST` to also accept `novarnish.*` subdomains (e.g. `novarnish.mysite.ddev.site`). Requests to these subdomains are piped directly to the backend by VCL, bypassing the cache without adding Varnish headers — useful for comparing cached vs. uncached responses.

> [!NOTE]
> If you use a `project_tld` other than `ddev.site` or `additional_fqdns`, DDEV adds `/etc/hosts` entries for your project hostnames automatically, but not for `novarnish.*` subdomains. Add them manually: `ddev hostname novarnish.mysite.example.com 127.0.0.1`.

## Helper Commands

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.

| Command | Description |
|------------------------------|-----------------------------------------------------------|
| `ddev varnishd` | Varnish-cli |
| `ddev varnishadm` | Control a running Varnish instance |
| `ddev varnishhist` | Display Varnish request histogram |
| `ddev varnishlog` | Display Varnish logs |
| `ddev varnishncsa` | Display Varnish logs in Apache / NCSA combined log format |
| `ddev varnishstat` | Display Varnish Cache statistics |
| `ddev varnishtest` | Test program for Varnish |
| `ddev varnishtop` | Display Varnish log entry ranking |
| `ddev varnish-config-reload` | Reloads the varnish current config to apply changes |
| `ddev describe` | View service status and used ports for Varnish |
| `ddev ssh -s varnish` | Go into the Varnish container shell |
| `ddev logs -s varnish` | Check Varnish logs |

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.

## Advanced Customization

## Explanation
You may want to edit the `.ddev/varnish/default.vcl` to meet your needs. The default VCL pipes `novarnish.*` requests directly to the backend (no caching, no Varnish headers). Remember to remove `#ddev-generated` from the file if you want your changes preserved.

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](https://github.com/ddev/ddev-contrib/blob/master/docker-compose-services/varnish/docker-compose.varnish.yml)
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.
To change the Docker image:

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`.
```bash
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:6.0
ddev add-on get ddev/ddev-varnish
ddev restart
```

Run `ddev get ddev/ddev-varnish` after changes to name, additional_hostnames, additional_fqdns, or project_tld in .ddev/config.yml so that .ddev/docker-compose.varnish-extras.yaml is regenerated.
Make sure to commit the `.ddev/.env.varnish` file to version control.

## Helper commands
All customization options (use with caution):

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.
| Variable | Flag | Default |
|---------------------------|-----------------------------|--------------------------------------------------------------------------------------------------------------------|
| `VARNISH_DOCKER_IMAGE` | `--varnish-docker-image` | `varnish:6.0` |
| `VARNISH_VARNISHD_PARAMS` | `--varnish-varnishd-params` | `-p http_max_hdr=1000 -p http_resp_hdr_len=1M -p http_resp_size=2M -p workspace_backend=3M -p workspace_client=3M` |

| Command | Description |
| --- | --- |
| `ddev varnishd` | Varnish-cli |
| `ddev varnishadm` | Control a running Varnish instance |
| `ddev varnishhist` | Display Varnish request histogram |
| `ddev varnishlog` | Display Varnish logs |
| `ddev varnishncsa` | Display Varnish logs in Apache / NCSA combined log format |
| `ddev varnishstat` | Display Varnish Cache statistics |
| `ddev varnishtest` | Test program for Varnish |
| `ddev varnishtop` | Display Varnish log entry ranking |
### VARNISH_VARNISHD_PARAMS

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.
Allows modifying the varnish [startup parameters](https://varnish-cache.org/docs/6.0/reference/varnishd.html).

## Additional Configuration
The provided defaults are set deliberately higher than what varnish usually defines.
The reason for this is that in development environments it is not uncommon to
have larger payloads either in HTML or HTTP-Headers. E.g. Drupals theme debugging
or cache tag handling.
Without increasing these limits, one might encounter hard to isolate errors like the following form nginx:
```
2025/07/15 09:01:01 [info] 1549#1549: *259 writev() failed (32: Broken pipe) while sending to client, client: 172.20.0.6, server: , request: "GET /en HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "myproject.ddev.site"
```

* 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.
## Credits

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

**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)**
Loading
Loading