Skip to content

Conversation

@adriendupuis
Copy link
Contributor

@adriendupuis adriendupuis commented Jan 8, 2026

Question Answer
JIRA Ticket N/A
Versions 5.0, 4.6
Edition All

How to add a reverse proxy Varnish or Fastly, into a DDEV cluster.

Preview https://ez-systems-developer-documentation--2999.com.readthedocs.build/en/2999/infrastructure_and_maintenance/clustering/clustering_with_ddev/#install-reverse-proxy

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Preview of modified files

Preview of modified Markdown:

@adriendupuis adriendupuis requested a review from reithor January 9, 2026 15:25
@adriendupuis adriendupuis marked this pull request as ready for review January 12, 2026 08:21
@adriendupuis adriendupuis requested a review from juskora January 12, 2026 08:52

The following sequence of commands:

1. Set some variables to distinguish Varnish versions, here for Varnish 7.1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Set some variables to distinguish Varnish versions, here for Varnish 7.1
1. Set some variables to distinguish between Varnish versions, here for Varnish 7.1

Comment on lines +48 to +60
VARNISH_VERSION=7.1
vcl_path=vcl_path
vcl_file=varnish7.vcl
mkdir -p .ddev/varnish
cp vendor/ibexa/http-cache/docs/varnish/vcl/$vcl_file .ddev/varnish/
sed 's/.host = "127.0.0.1";/.host = "web";/' vendor/ibexa/http-cache/docs/varnish/vcl/parameters.vcl > .ddev/varnish/parameters.vcl
sed -i '/^acl invalidators {$/a \\ "web";' .ddev/varnish/parameters.vcl
sed -i '/^acl debuggers {$/a \\ "0.0.0.0"/0; \/\/ debug from any IP' .ddev/varnish/parameters.vcl
if [[ $VARNISH_VERSION == 7.* ]]; then
sed -i 's/acl invalidators {/acl invalidators +log {/' .ddev/varnish/parameters.vcl
sed -i 's/acl debuggers {/acl debuggers +log {/' .ddev/varnish/parameters.vcl
fi
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:$VARNISH_VERSION --varnish-varnishd-params " -p $vcl_path=/etc/varnish -f /etc/varnish/$vcl_file"
Copy link
Contributor Author

@adriendupuis adriendupuis Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VARNISH_VERSION=7.1
vcl_path=vcl_path
vcl_file=varnish7.vcl
mkdir -p .ddev/varnish
cp vendor/ibexa/http-cache/docs/varnish/vcl/$vcl_file .ddev/varnish/
sed 's/.host = "127.0.0.1";/.host = "web";/' vendor/ibexa/http-cache/docs/varnish/vcl/parameters.vcl > .ddev/varnish/parameters.vcl
sed -i '/^acl invalidators {$/a \\ "web";' .ddev/varnish/parameters.vcl
sed -i '/^acl debuggers {$/a \\ "0.0.0.0"/0; \/\/ debug from any IP' .ddev/varnish/parameters.vcl
if [[ $VARNISH_VERSION == 7.* ]]; then
sed -i 's/acl invalidators {/acl invalidators +log {/' .ddev/varnish/parameters.vcl
sed -i 's/acl debuggers {/acl debuggers +log {/' .ddev/varnish/parameters.vcl
fi
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:$VARNISH_VERSION --varnish-varnishd-params " -p $vcl_path=/etc/varnish -f /etc/varnish/$vcl_file"
VARNISH_VERSION=7.1
mkdir -p .ddev/varnish
sed 's/.host = "127.0.0.1";/.host = "web";/' vendor/ibexa/http-cache/docs/varnish/vcl/parameters.vcl > .ddev/varnish/parameters.vcl
sed -i '/^acl invalidators {$/a \\ "web";' .ddev/varnish/parameters.vcl
sed -i '/^acl debuggers {$/a \\ "0.0.0.0"/0; \/\/ debug from any IP' .ddev/varnish/parameters.vcl
if [[ $VARNISH_VERSION == 7.* ]]; then
sed -i 's/acl invalidators {/acl invalidators +log {/' .ddev/varnish/parameters.vcl
sed -i 's/acl debuggers {/acl debuggers +log {/' .ddev/varnish/parameters.vcl
vcl_path=vcl_path
vcl_file=varnish7.vcl
fi
cp vendor/ibexa/http-cache/docs/varnish/vcl/$vcl_file .ddev/varnish/
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:$VARNISH_VERSION --varnish-varnishd-params " -p $vcl_path=/etc/varnish -f /etc/varnish/$vcl_file"

And update step descriptions accordingly

Comment on lines +71 to +77
To use Varnish 6.0LTS, set the following variables instead:

```bash
VARNISH_VERSION=6.0
vcl_path=vcl_dir
vcl_file=varnish6.vcl
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When minor variables are moved to the if, then:

Suggested change
To use Varnish 6.0LTS, set the following variables instead:
```bash
VARNISH_VERSION=6.0
vcl_path=vcl_dir
vcl_file=varnish6.vcl
```
To use Varnish 6.0LTS, set the following variable instead:
```bash
VARNISH_VERSION=6.0
```

You can see how the `web` server is responding to `varnish`:

```console
% curl -s -H "Surrogate-Capability: abc=ESI/1.0" http://127.0.0.1:<http-web-port>/product-catalog | grep 'esi:include'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:
Maybe a warning about the fact that the HTTPS (https://127.0.0.1:) URL probably fails?
But somehow, it shouldn't fail…

@reithor
Copy link
Contributor

reithor commented Jan 12, 2026

@adriendupuis : I tested by runing the following script on an existing project:

#!/bin/bash

VARNISH_VERSION=7.1
vcl_path=vcl_path
vcl_file=varnish7.vcl

mkdir -p .ddev/varnish
cp vendor/ibexa/http-cache/docs/varnish/vcl/$vcl_file .ddev/varnish/
sed 's/.host = "127.0.0.1";/.host = "web";/' vendor/ibexa/http-cache/docs/varnish/vcl/parameters.vcl > .ddev/varnish/parameters.vcl
sed -i '/^acl invalidators {$/a \\    "web";' .ddev/varnish/parameters.vcl
sed -i '/^acl debuggers {$/a \\    "0.0.0.0"/0; \/\/ debug from any IP' .ddev/varnish/parameters.vcl
if [[ $VARNISH_VERSION == 7.* ]]; then
  sed -i 's/acl invalidators {/acl invalidators +log {/' .ddev/varnish/parameters.vcl
  sed -i 's/acl debuggers {/acl debuggers +log {/' .ddev/varnish/parameters.vcl
fi
ddev dotenv set .ddev/.env.varnish --varnish-docker-image=varnish:$VARNISH_VERSION --varnish-varnishd-params " -p $vcl_path=/etc/varnish -f /etc/varnish/$vcl_file"

ddev get ddev/ddev-varnish

ddev config --web-environment-add HTTPCACHE_PURGE_SERVER=http://varnish
ddev config --web-environment-add HTTPCACHE_PURGE_TYPE=varnish
ddev config --web-environment-add TRUSTED_PROXIES=varnish

ddev restart

After this, responses still were showing x-cache-tags response header (should be Xkey).
I had to empty var/cache directory followed by running ddev restart to make it work.
After this cache purging by xkey was working fine.

Could you check/confirm ?

and:

curl -s -H "Surrogate-Capability: abc=ESI/1.0" https://127.0.0.1:<https-web-port> 

^ works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants