ddev: Non-ddev.site hostnames can't work on WSL2, and neither can ddev.site if DNS rebinding disallowed

Describe the bug

When the hostname required for a project is not *.ddev.site, or when DNS rebinding is not allowed, WSL2 browser stuff can’t work.

So:

  1. If DNS rebinding is disallowed, ddev will add the hostname to /etc/hosts. But unfortunately it’s the /etc/hosts in the WSL2 system, which is not the hosts file that the browser will use (which is C:\Windows\System32\drivers\etc\hosts). So the browser can’t recognize it.
  2. If project_tld is set to something other than ddev.site, same problem
  3. If additional_fqdns is set, that has the same problem.

I’m not sure there’s a good solution to this, because WSL2 code can’t change things on the Windows side…

Windows users can work around this issue by manually adding the needed hostnames to C:\Windows\System32\drivers\etc\hosts or by using the windows ddev to issue the command ddev hostname <neededfqdn> 127.0.0.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 27 (16 by maintainers)

Commits related to this issue

Most upvoted comments

This was resolved in DDEV v1.21.4, which now uses Windows-side hosts file management in this situation.

@steffenf14 if DNS rebinding isn’t allowed on your DNS server, you can:

  1. Change your computer’s DNS server to one that does allow DNS rebinding (Google’s 8.8.8.8, 8.8.4.4 or Cloudfront’s 1.1.1.1 for example) (Or change the DNS server handed out by your DHCP server)
  2. Allow DNS rebinding (see https://github.com/drud/ddev/issues/2533)
  3. Add hostnames on the Windows side either by editing the hosts file (above) or by using ddev hostname on the Windows side. Unfortunately, a hostname has to be added for each project/hostname.
  4. Use a browser inside WSL2 running X11. For example, use the X411 X server. Details about how to set this up are covered (for PHPStorm) in https://ddev.com/ddev-local/ddev-local-and-phpstorm-debugging-with-wsl2/