Dileet
Dileet

Reputation: 2074

Multiple servers within vagrant box

I have one main folder where I work on multiple projects with different languages. The box I use is https://github.com/fideloper/Vaprobash

I'm currently working on a project that uses elixir on the backend with port 4000 and then a node server for the frontend that is running on port 3000

My question is how do I run both servers at the same time?

I use apache vhost to access the specific project for example: projectname.192.168.22.10.nip.io:3000

Upvotes: 1

Views: 215

Answers (1)

Mech45
Mech45

Reputation: 339

Set multiple port forwarding on your 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
Add the auto correction if your are not sure about the host port :

    auto_correct: true
Then create a reverse proxy on the host (where the vagrant core is) with upstreams like :

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

Use nginx for the reverse proxy, its very simple to set :)

Upvotes: 1

Related Questions