In this post, we will look at exposing applications running on localhost through well formed local domains.

The reason that I have been exploring this functionality is because I often have to run many local micro services, and keep forgetting the ports on which they’re configured. Ergo helps solve this problem by routing the request on the custom local development domain (.dvp in my case) through a proxy.

Installation of Ergo, is pretty simple, as shown in the below commands.

Installation

Install Ergo on Mac OSx using the below commands as mentioned here:

brew tap cristianoliveira/tap
brew install ergo

Usage

In order to use Ergo, you need to first create a configuration file called .ergo

Ergo looks for a .ergo file inside the current directory. It must contain the names and URL of the services following the same format as /etc/hosts (domain+space+url). The main difference is it also considers the specified port.

touch ~/.ergo

The below instructions worked on my machine as I had issues with the auto proxy discovery.

First, I need to set up ergo to use a custom domain called .dvp.

This is due to conflicts mentioned in this issue and here, while using the .dev domain. .dvp suits my purpose!

Running Ergo

The command for running Ergo, using .dvp is shown below.

ergo run -domain .dvp

Adding a service to Ergo

Next, adding a service running on a custom port with a domain.dvp is as follows:

ergo add blog.n0c0de http://localhost:8086

Listing out all the existing domains

Listing out all the existing domains, is shown below:

ergo list -domain .dvp

Screenshot 2020-10-25 at 7.32.12 PM

Open Google Chrome using the Ergo proxy

As mentioned here, Google Chrome can be launched to use Ergo using:

open -a "Google Chrome" --args --proxy-pac-url=http://localhost:2000/proxy.pac
open -a "Google Chrome Canary" --args --proxy-pac-url=http://localhost:2000/proxy.pac

Enjoy!

Now just clicking on any of these domains sends you to the right URL. I no longer need to remember the ports on which those micro services are running. Easy peasy. Wonderful application. That makes my job. Much more organised.