Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local Domain Proxy

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.

Features

  • Map any custom domain to a local or LAN service
  • Automatic HTTPS with trusted mkcert certificates
  • Interactive terminal UI
  • Automatically discovers local and LAN services
  • No separate configuration database — nginx/default.conf is the single source of truth

Usage

./local-domain.sh

When 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.

Add

When adding a domain, the script:

  1. Prompts for the domain name.
  2. Scans for services running on the local machine and your local network.
  3. Displays the discovered services for selection.
  4. Allows manual entry of an ip:port destination if needed.

Remove

  • 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.

Domains and /etc/hosts

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.

About

Map custom domains to local or LAN services with trusted HTTPS using nginx, Docker, and mkcert.

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages