Skip to content

Instantly share code, notes, and snippets.

@BerkeleyTrue
Last active July 20, 2017 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BerkeleyTrue/39139dd4eeae68df1b2d to your computer and use it in GitHub Desktop.
Save BerkeleyTrue/39139dd4eeae68df1b2d to your computer and use it in GitHub Desktop.
Redirect a url to a localhost port
# First we need to map our localhost + port combo to another ip. You'll need root priviliges for this
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 -
# Now edit /etc/hosts
sudo vim /etc/hosts
# and add the following to the list
# NOTE: Do not edit anthing on this list you did not add
10.0.0.1 mydomain.dev
10.0.0.1 www.mydomain.dev
# I choose to use a .dev TLD as these are never going to conflict seeing how google has bought these TLD's
# and kept it for internal use only. You can use what ever you like
# Now browser to mydomain.dev or whatever you called it in your browser and presto!
It should load up whatever server you set up on port 3000
@konstantintuev
Copy link

This saved my life(or at least made it a lot easier), thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment