From my understanding, it seems that you only use one local dev machine, means not connected to any network that provides a DNS.
If i am right, i would suggest to setup things like described below :
step 1 : Assign at least two IP address to your MAC OS (one per domain), let's say :
To setup the second IP you will have to add a second Ethernet Adapter (logical not physical).
Step 2 : As you don't have a DNS server, you could setup your
/etc/hosts file, by adding :
Step 3 : Assign aliases to your loopback interface :
sudo ifconfig lo0 192.168.0.10 alias
sudo ifconfig lo0 192.168.0.11 alias
Step 4 : Setup
ipfw to forward packets :
sudo ipfw add fwd 127.0.0.1,123 tcp from me to 192.168.0.10 dst-port 80
sudo ipfw add fwd 127.0.0.1,456 tcp from me to 192.168.0.11 dst-port 80
You are done !
I've setup two
Node.js web servers to test your case :
$ netstat -anp tcp | grep -E "123|456"
tcp4 0 0 127.0.0.1:123 *.* LISTEN
tcp4 0 0 127.0.0.1:456 *.* LISTEN
Important : note that
ipfw rules and loopback interface aliases are not persistent and will no longer exist after a reboot. So consider adding a startup script.