juliushaertl / nextcloud-docker-dev

Nextcloud development environment using docker-compose
GNU Affero General Public License v3.0
134 stars 70 forks source link

Use `XXX.localhost` instead of `XXX.local` #171

Open provokateurin opened 1 year ago

provokateurin commented 1 year ago

XXX.localhost is set up on most linux systems to already resolve to 127.0.0.1, so adding the record to /etc/hosts would no longer be needed. Of course this can be changed in the env file, but I think this is a more useful default setup.

juliushaertl commented 1 year ago

Good point. Let's change that for new setups.

kesselb commented 4 months ago

I migrated my dev setup from .internal to .localhost a while ago and really like it! No longer dealing with /etc/hosts is a relief.

This week, I wanted to access my dev setup from a virtual machine and therefore created a Host-Only network. Host got 192.168.56.1 and guest 192.168.56.3. Inside the guest, I added an entry 192.168.56.1 server.localhost to the hosts file. Ping for server.localhost worked and also showed the right ip address, but Firefox and Chromium wouldn't open the page.

The reason is that most browsers and also newer curl versions added a special handling for localhost: https://daniel.haxx.se/blog/2021/05/31/curl-localhost-as-a-local-host/

provokateurin commented 4 months ago

So it doesn't work if you add the entry manually to the hosts file? I've used .localhost domains a few times already and never had any issues, but I also didn't add the hosts entry manually (libnss does it automatically).

kesselb commented 4 months ago

As long as server.localhost resolves to 127.0.0.x everything is all right. It becomes tricky if your .localhost domain should resolve a different IP address (e.g. 192.168.56.1 in my case).

I'm aware it's an edge case and using .localhost by default is nevertheless a good idea, but I would love to see a brief hint in the readme if we flip to .localhost about this limitation.

kesselb commented 4 months ago

More complex setup's should go with .internal as per https://www.icann.org/en/public-comment/proceeding/proposed-top-level-domain-string-for-private-use-24-01-2024