Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddev's management of /etc/hosts file could use one line per host, instead of putting all on one line #2817

Closed
alpham8 opened this issue Feb 17, 2021 · 4 comments

Comments

@alpham8
Copy link

alpham8 commented Feb 17, 2021

Is your feature request related to a problem? Please describe.
It's not really a problem, more likely an improvement for a faster work flow.

Describe the solution you'd like
Currently, ddev produces entries in /etc/hosts like this:

127.0.0.1 localhost mysite.ddev.site mysecondfqdn.com mythirdsite.org

Which are a few steps more if you'd like to go the production site instead of your local machine. The background:
Great online shop systems like Shopware have licensed plugins to a fully qualified domain and they only run in the local instance, if the domain entry matches the fqdn in /etc/hosts.

To make life easier, so for simple commenting out, it would be better to have one fqdn assignment to 127.0.0.1 like i. e. vagrant with the pluign vagrant-hostmanager does on the host machine. It wraps each written entry in an uuid block comment like this, so that the program can clearly identify its written entries based on that vagrant's start id (vagrant generates an hash on each vagrant up command, which is directly dumped out from that host manager plugin):

# some other entries
129.192.202.303

# vagrant-hostmager start-id fec11294-7158-11eb-9439-0242ac130002
127.0.0.1 mysite.ddev.site
127.0.0.1 mysecondsite.ddev.site
127.0.0.1 example.com
127.0.0.1 www.example.com
# vagrant-hostamanger start-id fec11294-7158-11eb-9439-0242ac130002

129.0.2939.3 othersite.com

Describe alternatives you've considered
Running a local dns server in the LAN like dnsmasq, but it's even much more complex and for most developers not really considerable.

Additional context
None

@rfay
Copy link
Member

rfay commented Feb 17, 2021

First, most people don't use the hosts file at all any more, they use *.ddev.site, which doesn't require mucking with the hosts file. But I can see your use case.

But I definitely wish that the library we depend on did one line per host. /etc/hosts alteration is little-used now though, so not likely to change.

@rfay rfay changed the title One line for each ddev hosts file entry ddev's management of /etc/hosts file could use one line per host, instead of putting all on one line Feb 17, 2021
@froemken
Copy link

Hello,

OS: MacOS Big Sur
Docker: 4.13.0
DDEV: 1.21.3

DDEV appends all local hostnames on my Mac in /etc/hosts in one line.

Currently, I have the problem that new hosts will not startup. "Network not reachable" while trying to access the new project in browser. I haven't count the local projects, but it could be ~300 *.ddev.site hostnames.

I found a very old issue ticket where a limitation of 4K each line takes affect:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/386791

For now I have remove some hostnames from the one-liner to get the project started.

Stefan

@rfay
Copy link
Member

rfay commented Oct 27, 2022

Hi @froemken - You must have a Fritzbox router I guess, or some other network situation that denies DNS rebinding, but usually it's Fritzbox routers. You'll be much happier with things if you fix that, see https://ddev.readthedocs.io/en/latest/users/basics/troubleshooting/#dns-rebinding-prohibited

@rfay
Copy link
Member

rfay commented Nov 30, 2022

Note that Windows 11 doesn't seem to have the 10-hosts-per-line problem any more.

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

No branches or pull requests

3 participants