HibiscusBlossom
HibiscusBlossom

Reputation: 11

Vagrant Port Forwarding Localhost 8080 and 8000 to Host 8080 and 8000

I am deploying an app on my Centos7 VM using Vagrant and Ansible. I can connect to the app on the VM through localhost:8080 and localhost8000. How can I use port forwarding to access the app on my host machine (Ex. I go to my web browser on my host machine and I can access the app through localhost:8080 and localhost:8000)?

Upvotes: 0

Views: 281

Answers (1)

Abhishek Kumar
Abhishek Kumar

Reputation: 452

You can use:

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

And for more info refer: https://www.vagrantup.com/docs/networking/forwarded_ports.html

After that if you face any issue. Please let me know.

Upvotes: 1

Related Questions