Skip to content

Conversation

@stasadev
Copy link
Member

The Issue

How This PR Solves The Issue

Varnish should run only for web:80, not for all ports.

This PR changes the logic to route web:80 through Varnish, while leaving everything else (Mailpit, web_extra_exposed_ports) unchanged.

This removes the need for novarnish.* subdomains.

Manual Testing Instructions

Prepare project:

mkdir varnish-test && cd varnish-test
printf "<?php\necho 'index' . PHP_EOL;\n" >index.php
ddev config --auto
mkdir -p php-extra
printf "<?php\necho 'php-extra' . PHP_EOL;\n" >php-extra/index.php
cat >>.ddev/config.yaml <<'EOF'
web_extra_daemons:
    - name: "php-extra"
      command: "php -S 0.0.0.0:20080"
      directory: /var/www/html/php-extra
web_extra_exposed_ports:
    - name: "php-extra"
      container_port: 20080
      http_port: 20080
      https_port: 20443
EOF

Install add-on:

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

And test it:

# All the URLs should work without any redirects:
ddev launch
ddev mailpit
ddev launch :20443

Only this url should have Varnish headers:

$ ddev exec 'curl -I $DDEV_PRIMARY_URL'
HTTP/2 200 
accept-ranges: bytes
age: 0
content-type: text/html; charset=UTF-8
date: Mon, 22 Sep 2025 13:09:22 GMT
server: nginx
vary: Accept-Encoding
via: 1.1 varnish (Varnish/6.0)
x-varnish: 2
content-length: 6

Mailpit: no Varnish headers:

$ ddev exec 'curl -I $DDEV_PRIMARY_URL:8026'
HTTP/2 405 
date: Mon, 22 Sep 2025 13:10:09 GMT

web_extra_exposed_ports: no Varnish headers:

$ ddev exec 'curl -I $DDEV_PRIMARY_URL:20443'
HTTP/2 200 
content-type: text/html; charset=UTF-8
date: Mon, 22 Sep 2025 13:11:00 GMT
host: varnish-test.ddev.site:20443
x-powered-by: PHP/8.3.25

Automated Testing Overview

I added test coverage for everything.

Release/Deployment Notes

This should be released as major v1.0.0.

@stasadev
Copy link
Member Author

@jedubois, please review, it should cover exactly the issue you reported.

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