Last Updated: August 15, 2019
·
41.76K
· 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...

Linux:

# localhost/loopback
sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --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 127.0.0.1,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 -> 127.0.0.1 port 3000
" | sudo pfctl -ef -

long - read this post:
https://salferrarello.com/mac-pfctl-port-forwarding/

over 1 year ago ·