1、適用場景
主機B不能直接訪問主機C
主機C能直接訪問主機B

問題:
公司內(nèi)網(wǎng)機器 10.3.20.102,有個 80 端口的 nginx 服務,想在外網(wǎng)可以直接訪問,比如在 192.168.1.254 機器上直接訪問 10.3.20.102:80 , 怎么實現(xiàn)?
2、配置 ssh 方向代理實現(xiàn)
// 10.3.20.102 上的配置
# curl 10.3.20.102:80
10.3.20.102
# ssh -fCNR 9998:localhost:80 root@120.77.154.31
root@120.77.154.31's password: 輸入 120.77.154.31 機器的密碼
# ps -ef|grep ssh
root 64758 1 0 Jul17 ? 00:00:06 sshd: root@pts/0
root 72706 1 0 13:49 ? 00:00:00 /usr/sbin/sshd -D
root 72858 72706 0 14:10 ? 00:00:00 sshd: root@pts/1
root 72921 1 0 14:27 ? 00:00:00 ssh -fCNR 9998:localhost:80 root@120.77.154.31
root 72923 64760 0 14:27 pts/0 00:00:00 grep --color=auto ssh
// 120.77.154.31 上的配置(買的云服務器)
# ssh -fCNL "*:80:localhost:9998" localhost
root@localhost's password: 輸入 120.77.154.31 機器的密碼
# ps -ef|grep ssh
root 1697 1 0 13:50 ? 00:00:00 /usr/sbin/sshd
root 1801 1697 0 14:07 ? 00:00:00 sshd: root@pts/0
root 1849 1697 0 14:10 ? 00:00:00 sshd: root
root 1854 1697 0 14:10 ? 00:00:00 sshd: root
root 1870 1697 0 14:27 ? 00:00:00 sshd: root
root 1875 1697 0 14:28 ? 00:00:00 sshd: root
root 1885 1 0 14:28 ? 00:00:00 ssh -fCNL *:80:localhost:9998 localhost
root 1898 1803 0 14:49 pts/0 00:00:00 grep ssh
3、192.168.1.254 上測試能否訪問 10.3.20.102:80 服務
# curl 120.77.154.31:80
10.3.20.102