Edit the hosts file
sudo nano /etc/hosts
Add this line somewhere after 127.0.0.1 localhost
:
127.0.0.1 your.domain.com
Save and exit (Ctrl + O, Ctrl + X). Flush the DNS cache:
dscacheutil -flushcache
###Port forwarding
Place the following code in /etc/pf.anchors/localhost.dev
:
rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 3000
NOTE: The trailing line break is required. Otherwise pf will say you have a syntax error.
Next, add two lines to /etc/pf.conf
to load your new rule. It is important where these lines go. Add this line right after rdr-anchor "com.apple/*"
:
rdr-anchor "localhost"
Add this line directly after load anchor "com.apple" from "/etc/pf.anchors/com.apple"
:
load anchor "pow" from "/etc/pf.anchors/com.pow"
Again, make sure to maintain the final line break.
Next, reload the rules into pf by running sudo pfctl -f /etc/pf.conf
Finally, enable pf by running sudo pfctl -e