通过 ssh 从外部 PC 作为 localhost 访问 http 服务器

Gla*_*ost 7 ssh-tunnel

我有一个正在工作的应用程序服务器,它只能接受来自本地主机的 http 请求。

在家里我通过 ssh 访问服务器。一旦进入服务器我就可以curl http://localhost/test.html

我想在家里的网络浏览器上执行相同的操作,即以某种方式通过 ssh 重定向我的浏览器流量并访问 test.html,就像我在服务器上一样。

我尝试ssh -v -D 9090 user@xx.xx.xx.xx过,在 Firefox 中通过 SOCKS v5 主机设置手动代理后:在 ip: 127.0.0.1 和端口 9090 上

我看到 ssh 调试中发生了一些事情,但看起来没有重定向到 80 服务器端口

小智 7

创建 SSH 隧道的正确语法是:

ssh -L local_port:remote_address:remote_port username@server.com
Run Code Online (Sandbox Code Playgroud)

因此,根据您的输出,命令应该类似于以下内容:

ssh -L 9090:localhost:80 username@server.com
Run Code Online (Sandbox Code Playgroud)

建立隧道后,您无需在 Firefox 上配置任何内容,只需输入 URL http://localhost:9090

希望这有帮助