在一个docker容器中,我在一个交互式shell中创建了以下隧道:
ssh -4 root@remotehost.com -L 8443:127.0.0.1:80在同一个容器的另一个shell中,我可以成功地运行以下命令:
curl http://localhost:8443服务器(remotehost.com)会使用HTML语言内容进行响应。
(注意:我现在使用纯HTTP,以使其更容易调试。最后,我需要使用HTTPS,这就是为什么我选择本地端口为8443。)
这个docker容器确实公开了它的端口8443:
# docker port be68e57bc3e0
8443/tcp -> 0.0.0.0:8443但是,当我尝试从主机连接到该端口时,我得到了以下信息:
# curl --verbose http://localhost:8443
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8443 (#0)
> GET / HTTP/1.1
> Host: localhost:8443
> User-Agent: curl/7.64.1
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection 0我迷路了。为什么它的行为与从容器内部连接时的行为不完全相同?我对SSH隧道有什么误解吗?
发布于 2020-09-18 19:18:31
解决方案是将-g标志添加到创建隧道的ssh行。
https://stackoverflow.com/questions/62793281
复制相似问题