如何使用 ssh 将本地服务代理给外部访问并保持 SSH 会话的连接性
server {listen localhost:80;server_name _;root /usr/share/nginx/html;# 重要:将请求转发到本地服务location / {root /usr/share/nginx/html;index index.html index.htm;proxy_pass http://127.0.0.1:10412;proxy_set_header Host $host:80;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Via "nginx";}
}
ssh-keygen -o
~/.ssh/authorized_keys
nohup ssh -N -v -R 10412:127.0.0.1:8088 root@{外部服务器的外网IP} 2>&1 &
nohup ssh -N -v -o ServerAliveInterval=10 -o ServerAliveCountMax=1000 -R 10412:127.0.0.1:8088 root@{外部服务器的外网IP} 2>&1 &