14

I found a way to forward ports 80 and 443 to other arbitrary ports (3000 and 3001 in my case) using ipfw. But ipfw is deprecated and replaced by pfctl. Here are my ipfw declarations:

sudo ipfw flush
sudo ipfw add 100 fwd 127.0.0.1,3000 tcp from any to me 443
sudo ipfw add 200 fwd 127.0.0.1,3001 tcp from any to me 80
sudo ipfw show

How can I do the same thing with pfctl please?

2

1 Answer 1

1

See this AskDifferent answer:

To forward all port 80 traffic to port 8080, you can enter the following from the Terminal command line.

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

Taken from https://salferrarello.com/mac-pfctl-port-forwarding/

To forward ports 80 and 443 to ports 3000 and 3001, use these commands:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .