While working on local projects, I often needed to test them under a real domain with proper ports and HTTPS. Running everything on localhost wasn't always enough, since browsers handle cookies, HSTS, mixed content, and other security features differently when a real domain is involved.
I ended up creating this tool to simplify that workflow. It might be useful for anyone who needs a realistic local development environment without setting up a full reverse proxy manually.
local-domain-proxy maps any custom domain to a local or LAN service and serves it over HTTPS using nginx and locally trusted certificates generated by mkcert.
- Map any custom domain to a local or LAN service
- Automatic HTTPS with trusted
mkcertcertificates - Interactive terminal UI
- Automatically discovers local and LAN services
- No separate configuration database —
nginx/default.confis the single source of truth
./local-domain.shWhen launched, the script displays the currently configured domains and presents an interactive menu with Add and Remove options. You can navigate using either the arrow keys or the corresponding menu numbers.
When adding a domain, the script:
- Prompts for the domain name.
- Scans for services running on the local machine and your local network.
- Displays the discovered services for selection.
- Allows manual entry of an
ip:portdestination if needed.
- If only one domain exists, it is removed immediately.
- If multiple domains exist, you'll be prompted to choose which one to remove.
The list of configured domains is derived directly from nginx/default.conf; no additional state or configuration files are maintained.
If you use a domain ending in .localhost (for example, myapp.localhost), the script does not need to modify /etc/hosts. According to RFC 6761, modern operating systems and browsers automatically resolve .localhost domains to 127.0.0.1.
For any other domain, the script first attempts to update /etc/hosts without elevated privileges. If the file is not writable by the current user, it automatically falls back to using sudo, since modifying /etc/hosts on Linux typically requires root privileges.