0

A user has 2 vagrant projects in their home directory. Mac OSX 10.8

The first vagrant instance was created months ago when the user was running an older version (1.1.x), the second instance was created with version 1.2.2. (Hence the vagrant file sytax is slightly different)

The problem is that the first instance (the older one) starts up, and successfully shows the apache welcome page when the user navigates to localhost:8080 using port forwarding. http://docs.vagrantup.com/v2/networking/forwarded_ports.html

The second instance does not show the apache welcome page.

Instance 1 (working)

Vagrant::Config.run do |config|

  config.vm.box = "lucid32"
  config.vm.provision :shell, :path => "bootstrap.sh"
  config.vm.network :bridged
  config.vm.forward_port 80, 8080

end

Instance 2 (not working)

Vagrant.configure("2") do |config|

  config.vm.box = "lucid32"
   config.vm.network :forwarded_port, guest: 80, host: 8080
   config.vm.network :public_network

   config.vm.provision :puppet do |puppet|
     puppet.manifests_path = "manifests"
     puppet.manifest_file  = "init.pp"
     config.vm.hostname = 'salesforce'
   end
end

I have verified the following:

Both instances have apache2 installed and running
I am able to run curl localhost:8080 and retrieve the html of the apache test page
I only ever have 1 instance running at a time to avoid conflicts with port 8080
Both instances are bound to the same network card

What could possibly be stopping the port forwarding from working on the newer vagrant instance?

spuder
  • 1,725
  • 3
  • 26
  • 42

2 Answers2

1

Instance 1 is bridged, while the other uses :public_network. Can you reach port 22 on the :public_network interface? (I hope you removed the insecure key and password).

Maybe you need a :host_only network as well?

mc0e
  • 5,866
  • 18
  • 31
  • From what I have researched, it looks like public_network is the new syntax for a bridged adapter. I tried copying this line from the working instance to the broken instance ( config.vm.network :bridged ), it spits back an error that the syntax is incorrect. I'm not sure what you mean if I can reach port 22 on the public. I can 'vagrant ssh' into both boxes – spuder Jun 06 '13 at 16:46
1

Figured it out thanks to this stackoverflow question. It was the firewall https://stackoverflow.com/questions/5984217/vagrants-port-forwarding-not-working

Verify that a hole is punched in the firewall for port 80 (or just turn off iptables)

 service iptables stop

Verify that curl is able to access the apache test page from inside the vm

vagrant ssh
curl -v localhost

Lastly verify that the Host can access the page through curl

exit
curl -v 'http://localhost:8080'
spuder
  • 1,725
  • 3
  • 26
  • 42