需要将内网服务映射到外网使用,条件限制不能通过端口映射实现。
看了下ngrok,好像需要域名什么,没进一步测试。
打算用ssh的端口转发功能,用autossh监控进行重连。
需要说明的是默认ssh远程转发只能绑定loop,需要打开服务器的sshd_config的GatewayPorts选项,改为yes或者clientspecified。
export AUTOSSH_PIDFILE=/var/run/autossh.pid
export AUTOSSH_POLL=60
export AUTOSSH_FIRST_POLL=30
export AUTOSSH_GATETIME=0
export AUTOSSH_DEBUG=1
autossh -f -M 0 -4 -N USER@HOST -p PORT -R *:8080:127.0.0.1:8080 \
-o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -o BatchMode=yes \
-o StrictHostKeyChecking=no &