5 ms·
Something nice about selfhosting on localhost with a modern linux machine (using systemd and systemd-resolved for DNS) is that by default *.localhost DNS querie
by qbasic_forever 4y ago
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.
- jve 4y ago> 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`
- qbasic_forever 4y agoOh nice! Had no idea they added that behavior.
- CoUHKT57BSe 4y agoIs 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
- dbetteridge 4y agoTry with a trailing slash whatever.localhost/
- CoUHKT57BSe 4y agomakes no difference, same error. ** one.one.one.one can't find whatever.localhost/: Non-existent domain
- dbetteridge 4y agoShame, that used to be the old trick to get windows to resolve local domains
- jve 4y agoInteresting. 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 :(
- WorldMaker 4y agoThat may be a feature of your current DNS provider, not Windows.
- bayindirh 4y agoThis 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.
- qbasic_forever 4y agoNo it's explicitly systemd-resolved behavior: https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html 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.
- chrisshroba 4y agoWill 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?
- qbasic_forever 4y agoCaddy 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.
- throw0101a 4y ago> 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.