Created
October 22, 2018 12:36
-
-
Save alvin4frnds/dfc7baf553d06122bb81d2e3161980bc to your computer and use it in GitHub Desktop.
I was able to get this working using the ifconfig and pfctl commands on Mac 10.10.2. With the following approach I'm successfully mapping 127.0.0.1:3000 to mydomain.com locally on my machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In your command line enter the following two commands to forward connections to 127.0.0.1:3000 to 10.0.0.1: | |
sudo ifconfig lo0 10.0.0.1 alias | |
echo "rdr pass on lo0 inet proto tcp from any to 10.0.0.1 port 80 -> 127.0.0.1 port 3000" | sudo pfctl -ef - | |
Then edit your /etc/hosts or /private/etc/hosts file and add the following line to map your domain to 10.0.0.1. | |
10.0.0.1 mydomain.com | |
After you save your hosts file flush your local DNS: | |
sudo discoveryutil udnsflushcaches | |
Now open mydomain.com in a browser and you'll be seeing the server hosted on your localhost port (i.e. 127.0.0.1:3000). Basically this process maps an <ip>:<port> to a new <ip> so that you can then map a host that IP. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment