重定向网络请求

sudo vim /etc/pf.conf

# 将本地向外请求80 定向到本地
rdr pass log on lo0 proto tcp from en0 to x.x.x.x port 80 -> 127.0.0.1 port 80
pass out on en0 route-to lo0 inet proto tcp from en0 to 50.28.102.240 port 80 keep state

# 配置生效
sudo pfctl -evf /etc/pf.conf

注:开机启动需要编辑文件 /System/Library/LaunchDaemons/com.apple.pfctl.plist

<string>pfctl</string>
<string>-e</string>
<string>-f</string>
<string>/etc/pf.conf</string>

参考:
https://serverfault.com/questions/421261/os-x-10-8-redirecting-locally-initiated-ssh-connections-to-localhost22
https://toutiao.io/posts/d7ljnp/preview