Last Updated: August 15, 2019
· seven1m

Forward Port 80 to Port 3000

You don't have to run your Rails app as root to access it on port 80. Instead, run it normally (on port 3000) and forward port 80 packets via iptables...


# localhost/loopback
sudo iptables -t nat -I OUTPUT -p tcp -d --dport 80 -j REDIRECT --to-ports 3000

# external
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000

Mac OS (This does not work in OSX Yosemite. If anyone knows how to do that, please comment!):

sudo ipfw add 1 forward,3000 ip from any to any 80 in

1 Response
Add your response

simple answer is:

echo "
rdr pass inet proto tcp from any to any port 80 -> port 3000
" | sudo pfctl -ef -

long - read this post:

over 1 year ago ·