我正在使用docker hub的容器,它是安装了ssh-client的Alpine。我试图在远程网络上转发一个https服务,并使用macvlan将其分配到本地IP。我正在使用下面的docker编译。
version: '3.3'
networks:
vlan100:
driver: macvlan
driver_opts:
parent: enp3s0
ipam:
config:
- subnet: 192.168.0.0/24
services:
dsm-over-ssh:
container_name: dsm-over-ssh
volumes:
- '~/.ssh:/root/.ssh'
command:
- '-L 443:192.168.1.3:5001'
- '-4'
- '[email protected]'
networks:
vlan100:
ipv4_address: 192.168.0.133
tty: true
image: occitech/ssh-client
所以我的想法是启动一个容器,让它永久地拥有 ssh -L 443:192.168.1.3:5001 -4 [email protected]
跑步。
当我跑的时候 docker exec -ti dsm-over-ssh /bin/sh
, apk add curl
, curl https://localhost -k
它显示了正确网站的代码。
然而,当我尝试访问 https:/192.168.0.133。 从同一网络上的不同计算机上的浏览器,它最终会超时并显示连接失败。
我可以加载同一服务器上同一vlan上的其他网站。我试过将端口设置为443:443,但还是失败了。https:/192.168.0.133。.
如果我尝试从同一网络上的另一台设备上进行curl,我得到的是 curl: (7) Couldn't connect to server
.
我这里可能漏掉了一些简单的东西,有人有什么想法吗?谢谢,我使用的是docker hub的容器,它是Alpine,安装了ssh-client。
和其他在Docker容器中运行的服务器型进程一样,你的ssh转发器需要配置为监听0.0.0.0 "所有接口 "的特殊地址;和许多服务器型进程一样,它默认为监听127.0.0.1 "只有容器私有的localhost "地址。 请参阅 -L
选项中 ssh(1)和对《公约》的描述 GatewayPorts
落入 ssh_config(5).
这意味着你需要在你的转发器中指定备用的绑定地址。
command:
- '-L0.0.0.0:443:192.168.1.3:5001'