【问题标题】:Multiple servers within vagrant boxvagrant box 内的多台服务器
【发布时间】:2017-01-12 19:14:36
【问题描述】:

我有一个主文件夹,用于处理不同语言的多个项目。我使用的盒子是https://github.com/fideloper/Vaprobash

我目前正在开发一个项目,该项目在后端使用 elixir,端口为 4000,然后为前端使用节点服务器,在端口 3000 上运行

我的问题是如何同时运行两台服务器?

我使用apache vhost来访问具体的项目例如:projectname.192.168.22.10.nip.io:3000

【问题讨论】:

    标签: ruby-on-rails node.js apache vagrant elixir


    【解决方案1】:

    在你的 Vagrantfile 上设置多端口转发:

    Vagrant.configure("2") do |config|
      config.vm.network "forwarded_port", guest: 3000, host: 12003, protocol: "tcp"
      config.vm.network "forwarded_port", guest: 4000, host: 12004, protocol: "tcp"
    end
    如果您不确定主机端口,请添加自动更正:

        auto_correct: true
    然后在主机(vagrant 核心所在的位置)上创建一个反向代理,上游如下:

    projectname.local will redirect to http://localhost:12003
    projectname-back.local wil redirect to http://localhost:12004

    反向代理使用nginx,设置非常简单:)

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 1970-01-01
      • 2014-06-10
      • 1970-01-01
      • 2020-07-29
      • 2015-01-31
      • 1970-01-01
      • 1970-01-01
      • 2023-04-08
      相关资源
      最近更新 更多