使用相同的端口转发规则为多个VM进行端口转发

 S晓晓宋五 发布于 2023-02-11 13:37

我目前有一个vagrant环境,每个VM都有一个从主机到客户端的端口转发规则设置.但是,此转发规则的问题在于,我不能同时使用类似的端口转发规则通过vagrant运行多个VM.

似乎我需要某种端口代理来处理这个问题.是否有一些已经融入vagrant/virtualbox的东西可以支持这个?

Traceback from Vagrant when I try running another VM with the same forwarding rules:
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8000 is already in use
on the host machine.

To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:

 config.vm.network :forwarded_port, guest: 8000, host: 1234

Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.

Golo Roden.. 9

您可以使用该:auto_correct参数进行端口定义,然后Vagrant将查找另一个(未使用的)端口:

Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
end

有关详细信息,请参阅文档.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有