Hi @callumbee — that's a really interesting use-case. Indigo itself is fully capable of supporting wildcard domains. The only real issue is getting that traffic sent to Indigo.
The following options are untested, so let me know if you get stuck.
Configure your site for wildcard subdomains.
Assuming you're using Nginx, in your Indigo site config, add a leading *.
to the domain. For example, *.mysite.test
. Apache is slightly more complex, and will require you to override the vhost config to supply your own ServerName
and ServerAlias
.
Tell your Mac to send traffic for those domains to Indigo.
This is where things get more interesting.
Option 1
You may be aware that Indigo adds an entry for each domain into your /etc/hosts
file. Your mac checks here when you visit that domain in your browser, so it knows where to send that traffic.
So if (in your dev environment at least) you know exactly, or can predict, which subdomains you need to use, you could manually bulk add them to your hosts
file (or write a script to do it periodically or something).
Option 2
If you truly need to respond to any wildcard domain and have no prior way to know what each will be, the definitive way is to use dnsmasq. Indigo used to ship with dnsmasq, and used that instead of writing to the hosts file. However we came up against all manner of ugly edge-cases where certain routers would cache DNS entries, IPv6 entries were cached separately in some cases etc etc However, for a single developer, it is probably the most robust solution. It's not terribly difficult to install and configure, but it's all outside of Indigo.
Option 3
Use a *.localhost
domain. Most browsers and macOS resolve *.localhost
to 127.0.0.1
automatically. So in Indigo, define your site as *.localhost
and you'll be able to access your site at any url such as mysite.localhost
and another.localhost
. There are some caveats to this option; it's up to the browser vendor whether they implement this; it is not using your Mac's usual DNS resolution chain. Also, apps other than browsers are unlikely to resolve these domains.
Option 4
Similar to #3 above, there are several domains which point at 127.0.0.1. This article provides an overview. I haven't tried these (yet) but as I understand it you'll get browser certificate authenticity warnings, because Indigo can't generate a trusted SSL cert for those domains.
Let me know how you go or if you get stuck!