Wildcard Localhost Subdomains for Development
tl;dr you can use *.l.sd.ai
to resolve any domain you like to 127.0.0.1
.
Using a wildcard domain for localhost
There are certain situations where you might be working in an environment that requires a locally virtual-hosted environment but a domain that looks like a real-world one. For example, you might be working on an OAuth client where the server wants you to have an actual domain name for the callback URL.
On a lot of systems, *.localhost
will resolve and the SSO server will allow
you to add this as a callback URL, which is fine. However, this may not be
enough when:
- You need to virtual-host several systems locally, so need multiple domains.
- Your system doesn’t resolve
*.localhost
(e.g. Debian), or: - The SSO server only permits
localhost
, and not subdomains oflocalhost
.
I’ve added a wildcard entry for *.l.sd.ai
on my domain, so this can be used
for testing in such an environment which resolbes to 127.0.0.1
. Obviously this
won’t enable you to make things avalable to other parts of the internet, but
will allow you to quickly add a new domain in a development envronment.
This entry is hosted on Cloudflare, so should be pretty accessible.