How to replace localhost port numbers with custom local domains using HAProxy and mkcert
Developers working with multiple local apps often juggle hard-to-remember port numbers like localhost:46176, which can be replaced with cleaner custom domain names such as omnideck.omni. The setup uses HAProxy as a reverse proxy, mkcert for local HTTPS certificates, and Homebrew for installation and service management on macOS or Linux. Custom hostnames are mapped to 127.0.0.1 via the /etc/hosts file, while HAProxy listens on port 80 and forwards requests to the correct local port based on the domain name. This approach improves readability, enables testing of production-like behavior for cookies, CORS, and OAuth redirects, and allows multiple apps to run simultaneously without port conflicts. A key security step involves restricting HAProxy's wildcard bind to loopback addresses only, preventing external devices on the same network from reaching the local apps.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in