News for hackers. Stuff that matters.
Re:Selfhosting on Localhost by qbasic_forever on Tuesday July 05, 2022 @11:23AM (#31989303)
Something nice about selfhosting on localhost with a modern linux machine (using systemd and systemd-resolved for DNS) is that by default *.localhost DNS queries are routed to localhost. So you can setup your local apps to have domain names like "photos.localhost", "code.localhost", etc. and not have to muck with hostname entries and such.

Setup caddy as a reverse proxy and it will automatically inject a local CA cert into your browsers and auto provision local SSL certs too so you can access local services by names instead of ports, and everything happily works with SSL automagically.

I really, really wish windows and mac had a similar behavior to just route all *.localhost queries to localhost.

Re:Selfhosting on Localhost by throw0101a on Wednesday July 06, 2022 @07:30PM (#32008183)
> I really, really wish windows and mac had a similar behavior to just route all *.localhost queries to localhost.

I'm happy they don't: DNS queries should be routed to whatever I have in /etc/resolv.conf.

If I have a Pi-Hole or use 8.8.8.8, then *.localhost stuff should not be injected in some clever fashion.

If you happen to use 127.0.0.53 (or whatever) on Linux and 'magic' happens, that's on you. But the system should fiddle with things othwerise.

Re:Selfhosting on Localhost by jve on Tuesday July 05, 2022 @11:34AM (#31989441)
> I really, really wish windows and mac had a similar behavior to just route all *.localhost queries to localhost.

Windows 10 has it. Try `nslookup whatever.localhost`

Re:Selfhosting on Localhost by CoUHKT57BSe on Tuesday July 05, 2022 @12:06PM (#31989977)
Is this some setting you have to enable? cause none of my 3 Windows 10/11 machines to hand do this, I just get the following error.

** one.one.one.one can't find whatever.localhost: Non-existent domain

Re:Selfhosting on Localhost by jve on Tuesday July 05, 2022 @03:53PM (#31992887)
Interesting.

Tried on Win10Home 21H2 (19044.1766) and it doesn't work.

On Win10Enterprise 21H2 (19044.1706) it works.

I cannot find a documentation reference on the feature of resolving *.localhost

Sorry guys, it turned out that our corporate DNS server is giving the answers. Once I disconnected from VPN, no longer did it work :(

Re:Selfhosting on Localhost by dbetteridge on Tuesday July 05, 2022 @01:36PM (#31991249)
Try with a trailing slash

whatever.localhost/

Re:Selfhosting on Localhost by CoUHKT57BSe on Tuesday July 05, 2022 @03:56PM (#31992921)
makes no difference, same error. ** one.one.one.one can't find whatever.localhost/: Non-existent domain
Re:Selfhosting on Localhost by dbetteridge on Wednesday July 06, 2022 @07:13AM (#31999297)
Shame, that used to be the old trick to get windows to resolve local domains
Re:Selfhosting on Localhost by WorldMaker on Tuesday July 05, 2022 @03:05PM (#31992346)
That may be a feature of your current DNS provider, not Windows.
Re:Selfhosting on Localhost by qbasic_forever on Tuesday July 05, 2022 @11:40AM (#31989532)
Oh nice! Had no idea they added that behavior.
Re:Selfhosting on Localhost by bayindirh on Tuesday July 05, 2022 @12:01PM (#31989893)
This is not about systemd-resolved but it's just mDNS/Bonjour.

I think .local and .localhost domains are working on my home network for more than five years, even with systems which do not run systemd-resolved as of today.

Re:Selfhosting on Localhost by qbasic_forever on Tuesday July 05, 2022 @03:51PM (#31992856)
No it's explicitly systemd-resolved behavior: https://www.freedesktop.org/software/systemd/man/systemd-res...

> The hostnames "localhost" and "localhost.localdomain" as well as any hostname ending in ".localhost" or ".localhost.localdomain" are resolved to the IP addresses 127.0.0.1 and ::1.

mDNS only uses the .local suffix but AFAIK it will never resolve anything to localhost on that domain. I'm pretty sure having a mDNS service that advertises a .local domain as 127.0.0.1 would really break things too if it serves that address up to other machines on your network.

Re:Selfhosting on Localhost by chrisshroba on Tuesday July 05, 2022 @01:59PM (#31991563)
Will the local CA certs generate security errors in modern browsers since they’re being issued for a domain (e.g. photos.localhost) that obviously can’t be verified to a CA like Let’s Encrypt?
Re:Selfhosting on Localhost by qbasic_forever on Tuesday July 05, 2022 @03:50PM (#31992838)
Caddy uses a library from step certificates which injects a self signed CA cert into your browser and OS trust stores automatically, so your browser will actually be perfectly happy with the SSL certs. The first time you run caddy it will prompt to elevate privilege so it can install the certs and then it should be good to go after that point.