赞
踩
有时候在对接第三方服务时,需要将外网流量转发到本地,方便调试。
这个可以使用ssh的远程转发功能实现,关于ssh转发,这里有一篇比较好的文章:
https://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/
外网转发流量到本地,需要有一台外网服务器做转发工作。
sudo vi /etc/ssh/sshd_config
增加:
gatewayports yes # 让其他机器可以访问
ClientAliveInterval 60 # 保持连接
ClientAliveCountMax 1
重启:
/etc/init.d/ssh restart
ssh -g -R 80:localhost:8080 user@remote_server -p xxxx
意思是转发远程服务器的80端口到本地机器的8080端口,ssh到user@remote_server -p xxxx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。